home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / text / print / GraphPaper_src.lha / MathPaperPrint2.S
Text File  |  1997-09-23  |  49KB  |  2,511 lines

  1. **********
  2. ********** Printroutine voor verschillende types papier
  3. **********
  4. **********  door Maurice van Wanum  © 1996/1997
  5. **********
  6.  
  7.     incdir    ASM-One:
  8.     incdir    Include2.0:
  9. * standaard macros *
  10.     include    Macros.S
  11. * exec *
  12.     include    exec/exec_lib.i
  13.     include    exec/types.i
  14.     include    exec/memory.i
  15.     include exec/ports.i
  16.     include devices/printer.i
  17.     include devices/prtbase.i
  18. * dos *
  19.     include    libraries/dos_lib.i
  20.     include    libraries/dos.i
  21. * graphics *
  22.     include    graphics/graphics_lib.i
  23.     include    graphics/gfx.i
  24.     include    graphics/rastport.i
  25. * intuition *
  26.     include    intuition/intuition.i
  27.     include    intuition/intuition_lib.i
  28. * gadtools *
  29.     include    libraries/gadtools.i
  30.     include    libraries/gadtools_lib.i
  31. * workbench *
  32.     include workbench/workbench.i
  33.     include workbench/startup.i
  34.     include workbench/icon_lib.i
  35.  
  36.         
  37. Fix    =-30    ; offsets van de Mathffp.lib
  38. Flt    =-36
  39. Neg    =-60
  40. Add    =-66
  41. Sub    =-72
  42. Mul    =-78
  43. Div    =-84
  44.  
  45. _LVOFix    =-30    ; offsets van de Mathffp.lib
  46. _LVOFlt    =-36
  47. _LVOCmp    =-42
  48. _LVONeg    =-60
  49. _LVOAdd    =-66
  50. _LVOSub    =-72
  51. _LVOMul    =-78
  52. _LVODiv    =-84
  53.  
  54. Macht    =-90    ; offsets van de mathtrans.lib
  55. Log10    =-126
  56.  
  57. LogPapier    equ    1
  58. AntiLogPapier    equ    2
  59. LincmPapier    equ    3
  60. LinhalfPapier    equ    4
  61. LinmmPapier    equ    5
  62.  
  63. half        equ    $80000040
  64. cmpinch        equ    $c993263f
  65. tiende        equ    $cccccd3d
  66. WFLAG    SET    ACTIVATE!WINDOWDRAG!WINDOWDEPTH!WINDOWCLOSE
  67. WFLAG    SET    WFLAG!SIMPLE_REFRESH!WFLG_RMBTRAP
  68.  
  69.  
  70. ; Use lowest non-obsolete version that supplies the functions you need.
  71. INTUITION_REV     equ    37
  72. NULL        equ    0
  73.  
  74.  
  75. lib    MACRO
  76.     Lib    \1
  77.     ENDM
  78.  
  79. save    = 0
  80. debug    = 0        extra info
  81.  
  82. Startup    move.l    4.w,a6
  83.  if save
  84.  
  85.     AUTO    WO\
  86.     
  87.     sub.l    a1,a1
  88.     Lib    FindTask        ; onze task zoeken
  89.     move.l    d0,a2
  90.     tst.l    $ac(a2)
  91.     bne.W    CLIStart        ; geen 0 -> vanuit CLI (of Shell)
  92.             ; Workbench-Startup
  93.     lea    $5c(a2),a0
  94.     Lib    WaitPort
  95.     lea    $5c(a2),a0
  96.     Lib    GetMsg
  97.     push.l    d0
  98.     bsr.s    GetPrefs
  99.     bsr.w    CLIStart
  100.     pop.l    a1
  101.     move.l    4.w,a6
  102.     LibJ    ReplyMsg        reply-message
  103.  
  104. GetPrefs
  105.     OpenLib    iconnaam
  106.     tst.l    d0
  107.     beq.b    .noiconlib            helaas geen icon.lib ??
  108.     move.l    d0,a5
  109.     OpenLib    dosnaam
  110.     move.l    d0,a6
  111.     move.l    4(SP),a2        WB-Message
  112.     move.l    sm_NumArgs(a2),d2    aantal argumenten
  113.     subq.l    #1,d2
  114.     bcs.b    .noargs
  115.     move.l    sm_ArgList(a2),a2
  116. .nexticon
  117.     move.l    (a2)+,d1
  118.     Lib    CurrentDir        pas dir aan
  119.     move.l    (a2)+,a0
  120.     exg    a5,a6
  121.     Lib    GetDiskObject        haal icon
  122.     tst.l    d0
  123.     beq.s    .noicon                -> geen icon
  124.     push.l    d0
  125.     move.l    d0,a0
  126.     move.l    do_ToolTypes(a0),a3    a3 = tooltype-array
  127.     bsr.s    GetToolTypes        zoek tooltypes uit
  128.     pop.l    a0
  129.     Lib    FreeDiskObject        geef icon weer vrij
  130. .noicon
  131.     exg    a5,a6
  132.     dbf    d2,.nexticon    
  133. .noargs
  134.     move.l    a6,a1
  135.     move.l    4.w,a6
  136.     Lib    CloseLibrary
  137.     move.l    a5,a1
  138.     Lib    CloseLibrary
  139. .noiconlib
  140.     rts
  141.  
  142. ****** in : a3 = tooltype-array
  143. GetToolTypes
  144.     push.l    a2
  145. *** doe windowposities
  146.     lea    newwin(PC),a2
  147.     lea    _MAINPOS(PC),a4
  148.     bsr.w    GetWinPos        hoofdwindow
  149.     lea    InstelWin(PC),a2
  150.     bsr.w    GetWinPos        instelwindow
  151.     lea    AbortWin(PC),a2
  152.     bsr.w    GetWinPos        afbreekwindow
  153. *** doe eenheden
  154.     lea    _EENH(PC),a1
  155.     moveq    #'X',d0
  156.     bsr.w    FindTool        x eenheden
  157.     beq.s    .yeenh
  158.     move.l    d0,a0
  159.     bsr.w    Getnum
  160.     move.l    d0,xEenheden
  161. .yeenh    lea    _EENH(PC),a1
  162.     moveq    #'Y',d0
  163.     bsr.w    FindTool        y eenheden
  164.     beq.s    .donums
  165.     move.l    d0,a0
  166.     bsr.w    Getnum
  167.     move.l    d0,yEenheden
  168. *** doe de X-waardes
  169. ** numerieke waardes
  170. .donums    move.l    a3,a0
  171.     lea    xPrimdkt(PC),a2
  172.     moveq    #'X',d3
  173.     bsr.w    ZoekDiktes        zoek prim, sec en tert diktes
  174.     lea    _LOGBRD(PC),a1
  175.     move.l    a3,a0
  176.     Lib    FindToolType        decade-breedte
  177.     tst.l    d0
  178.     beq.s    .xpaper
  179.     move.l    d0,a0
  180.     bsr.w    Getnum
  181.     move.l    d0,xDecbrd
  182. ** papiertype
  183. .xpaper    lea    _PAPER(PC),A1
  184.     moveq    #'X',d0
  185.     bsr.b    FindTool    papier X
  186.     beq.s    .yprefs
  187.     bsr.w    GetIconPaper
  188.     tst    d4
  189.     bmi.s    .yprefs
  190.     addq    #1,d4
  191.     move.b    d4,xType        zet type papier
  192. *** doe y-waardes
  193. ** numerieke waardes
  194. .yprefs    move.l    a3,a0
  195.     lea    yPrimdkt(PC),a2
  196.     moveq    #'Y',d3
  197.     bsr.w    ZoekDiktes        zoek prim, sec en tert diktes
  198.     lea    _LOGHGT(PC),a1
  199.     move.l    a3,a0
  200.     Lib    FindToolType        decade-hoogte
  201.     tst.l    d0
  202.     beq.s    .ypaper
  203.     move.l    d0,a0
  204.     bsr.w    Getnum
  205.     move.l    d0,yDecbrd
  206. ** papier-type
  207. .ypaper    lea    _PAPER(PC),A1
  208.     moveq    #'Y',d0
  209.     bsr.b    FindTool    papier Y
  210.     beq.b    .exit
  211.     bsr.b    GetIconPaper
  212.     tst.w    d4
  213.     bmi.b    .exit
  214.     addq    #1,d4
  215.     move.b    d4,yType        zet type papier
  216. *** klaar
  217. .exit    pop.l    a2
  218.     rts
  219.  
  220. *** in : a0 = string
  221. ***      d0 = 'X' of 'Y'
  222. ZetXY    tst.b    (a0)+
  223.     bne.s    ZetXY
  224. .1    cmp.b    #'_',-(a0)
  225.     bne.s    .1
  226.     move.b    d0,1(a0)
  227.     rts
  228.  
  229. **** in  : a1 = string
  230. ****       a3 = tooltypearray
  231. ****       d0 = 'X' of 'Y'
  232. **** uit : d0 = pointer naar tooltype
  233. ****       a0 = d0
  234. ****       SR = tst.l    d0
  235. FindTool
  236.     move.l    a1,a0
  237.     bsr.s    ZetXY
  238.     move.l    a3,a0
  239.     Lib    FindToolType
  240.     move.l    d0,a0
  241.     tst.l    d0
  242.     rts
  243.  
  244. ***** Zoek de positie van het window uit
  245. ***** in  : a4 = naam van x/y positie
  246. *****       a3 = tooltypearray
  247. *****       a2 = pointer naar newwindow-struct
  248. ***** uit : a4 = volgende naam
  249. GetWinPos
  250.     move.l    a4,a1
  251.     moveq    #'X',d0
  252.     bsr.b    FindTool
  253.     beq.s    .ypos
  254.     bsr.b    Getnum
  255.     move    d0,(a2)+
  256. .ypos    move.l    a4,a1
  257.     moveq    #'Y',d0
  258.     bsr.b    FindTool
  259.     beq.s    .ex
  260.     bsr.b    Getnum
  261.     move    d0,(a2)+
  262. .ex    tst.b    (a4)+
  263.     bne.s    .ex
  264.     rts
  265.  
  266. ****** in : d0=tooltype
  267. ****** uit: d4=gadno
  268. GetIconPaper
  269.     move.l    d0,a2
  270.     lea    typetab(PC),a4
  271.     moveq    #4,d4
  272. .lus    move    (a4)+,d0
  273.     lea    -2(a4,d0.w),a1
  274.     move.l    a2,a0
  275.     Lib    MatchToolValue
  276.     tst.l    d0
  277.     bne.s    .found
  278.     move    (a4)+,d0
  279.     lea    -2(a4,d0.w),a1
  280.     move.l    a2,a0
  281.     Lib    MatchToolValue
  282.     tst.l    d0
  283.     dbNe    d4,.lus        
  284. .found    rts
  285.  
  286. typetab    Dr.w    _MM,_MM2
  287.     Dr.w    _HALCM,_HALCM2
  288.     Dr.w    _CM,_CM2
  289.     Dr.w    _ALOG,_ALOG2
  290.     dr.w    _LOG,_LOG2
  291.         
  292. ***** scratch : a0/a1/a2/a4/d0/d1/d4
  293. ***** in : d3 = 'X' of 'Y'
  294. *****      a2 = PrefsUit
  295. *****      a3 = ToolTypeArray
  296. ***** uit: --
  297. ZoekDiktes
  298.     moveq    #2,d4
  299.     lea    tooltab(PC),a4
  300. .lus    move    (a4)+,d0
  301.     lea    -2(a4,d0.w),a1
  302.     move    d3,d0
  303.     bsr.b    FindTool
  304.     beq.s    .next            niet gevonden
  305.     bsr.b    Getnum
  306.     move.l    d0,(a2)
  307. .next    addq    #4,a2
  308.     dbf    d4,.lus
  309.     rts
  310.  
  311. tooltab    dr.w    _PRIM
  312.     dr.w    _SEC
  313.     dr.w    _TER    
  314.  
  315. **** scratch : d0/d1/a0
  316. **** in : a0 = string
  317. **** uit: d0 = getal
  318. Getnum    moveq    #0,d0
  319. .space    move.b    (a0)+,d1
  320.     cmp.b    #' ',d1        sla spaties over
  321.     beq.s    .space
  322. .next    cmp.b    #'9',d1
  323.     bhi.s    .nonum
  324.     cmp.b    #'0',d1
  325.     blo.s    .nonum
  326.     and.w    #$f,d1
  327.     mulu    #10,d0
  328.     add.w    d1,d0
  329.     move.b    (a0)+,d1
  330.     bra.s    .next
  331. .nonum    rts
  332.  
  333. **** window-posities is nog te doen
  334. _MAINPOS    DC.B    'WINDOW_XPOS',0
  335. _INSTELPOS    DC.B    'INSTELWINDOW_XPOS',0
  336. _PRINTPOS    DC.B    'PRINTWINDOW_XPOS',0
  337.  
  338. **** algemene printopties
  339. _PRIM    dc.b    'PRIMAIRE_DIKTE_X',0
  340. _SEC    dc.b    'SECUNDAIRE_DIKTE_X',0
  341. _TER    dc.b    'TERTIAIRE_DIKTE_X',0
  342. _PAPER    dc.b    'PAPIERSOORT_X',0
  343. _LOG    dc.b    'LOGARITMISCH',0
  344. _LOG2    DC.B    'LOG',0
  345. _ALOG    DC.B    'ANTI_LOGARITMISCH',0
  346. _ALOG2    DC.B    'ALOG',0
  347. _CM    DC.B    'CENTIMETER',0
  348. _CM2    DC.B    'CM',0
  349. _MM    DC.B    'MILLIMETER',0
  350. _MM2    DC.B    'MM',0
  351. _HALCM    DC.B    'HALVE_CENTIMETER',0
  352. _HALCM2    DC.B    '½CM',0
  353. _LOGBRD    dc.b    'LOG_BREEDTE',0
  354. _LOGHGT    dc.b    'LOG_HOOGTE',0
  355. _EENH    dc.b    'EENHEDEN_X',0
  356.     even
  357.  
  358. CLIStart
  359.  endif
  360.     move.l    #datasize,d0
  361.     move.l    #MEMF_CLEAR,d1
  362.     Lib    AllocMem        geheugen voor variabelen
  363.     move.l    d0,a4
  364.     tst.l    d0
  365.     beq.w    nomem
  366.     OpenLib    dosnaam            open dos.lib
  367.     move.l    d0,DosBase(a4)
  368.     OpenLib    intuition,INTUITION_REV
  369.     move.l    d0,intbase(a4)        open int.lib
  370.     beq.w    noint
  371.     OpenLib    graphics
  372.     move.l    d0,gfxbase(a4)        open gfx.lib
  373.     beq.w    nogfx
  374. retrygadlib
  375.     OpenLib    gadnaam
  376.     move.l    d0,gadbase(a4)
  377.     beq.b    NoGTlib
  378.  
  379.   if debug
  380.     lea    ConName(PC),a0
  381.     move.l    a0,d1
  382.     move.l    #MODE_OLDFILE,d2
  383.     move.l    DosBase(a4),a6
  384.     Lib    Open
  385.     move.l    d0,ConHD
  386.     beq    NoCon
  387.   endif
  388. RetryMathTR
  389.     move.l    4.w,a6
  390.     lea    MathTRName(PC),a1
  391.     Lib    OldOpenLibrary
  392.     move.l    d0,MathTR(a4)
  393.     beq.b    NoMathTR
  394. RetryMath
  395.     lea    MathName(PC),a1
  396.     Lib    OldOpenLibrary
  397.     move.l    d0,a6
  398.     move.l    d0,Math(a4)
  399.     beq.b    NoMath
  400.  
  401.     push.l    a4
  402.     bsr.w    main
  403.     pop.l    a4
  404.     bra.b    Einde
  405.  
  406. ;====== foutroutines en afsluiten
  407. NoMath
  408.   if debug
  409.     lea    _NoMath(PC),a0
  410.     bsr    print
  411.     bra    NoMathClose
  412.   else
  413.     lea    MathName(PC),a0
  414.     lea    RetryMath(PC),a1
  415.     lea    NoMathClose(PC),a2
  416.     bra.b    AutoReq
  417.   endif
  418.     
  419. NoMathTR
  420.   if debug
  421.     lea    _NoMathTR(PC),a0
  422.     bsr    print
  423.     bra    NoMathTRClose
  424.   else
  425.     lea    MathTRName(PC),a0
  426.     lea    RetryMathTR(PC),a1
  427.     lea    NoMathTRClose(PC),a2
  428.     bra.b    AutoReq
  429.   endif
  430.  
  431. NoGTlib    lea    gadnaam(PC),a0
  432.     lea    retrygadlib(PC),a1
  433.     lea    nogadtools(PC),a2
  434.     bra.b    AutoReq
  435.     
  436. ******* afsluiten van programma's
  437. Einde    move.l    Math(a4),a1    sluit mathffp.lib
  438.     move.l    4.w,a6
  439.     Lib    CloseLibrary
  440. NoMathClose
  441.     move.l    MathTR(a4),a1    sluit mathtrans.lib
  442.     move.l    4.w,a6
  443.     Lib    CloseLibrary
  444. NoMathTRClose
  445.   if debug
  446.     lea    _TVV(PC),a0
  447.     bsr    print        'toets voor verder'
  448.     move.l    ConHD(PC),d1
  449.     lea    _Buff(PC),a0
  450.     move.l    a0,d2
  451.     moveq    #1,d3
  452.     move.l    DosBase(a4),a6
  453.     lib    Read        lees een toets
  454.     move.l    ConHD(PC),d1    sluit con-window
  455.     Lib    Close
  456.   endif
  457. NoCon
  458. libclose
  459.     move.l    4.w,a6
  460.     move.l    gadbase(a4),a1
  461.     Lib    CloseLibrary        sluit gadtools.lib
  462. nogadtools
  463.     move.l    gfxbase(a4),a1
  464.     Lib    CloseLibrary        sluit gfx.lib
  465. nogfx
  466.     move.l    intbase(a4),a1
  467.     Lib    CloseLibrary        sluit int.lib
  468. noint    move.l    DosBase(a4),a1
  469.     Lib    CloseLibrary        sluit dos.lib
  470.  
  471.     move.l    a4,a1
  472.     move.l    #datasize,d0
  473.     Lib    FreeMem            geef geheugen terug
  474.  
  475.     moveq    #0,d0            ok-waarde
  476.     rts
  477.  
  478. nomem    moveq    #103,d0            foutwaarde : te weinig geheugen
  479.     rts
  480.  
  481.  
  482. ***** Een routine die een Easyrequester-gebruikt
  483. ***** in  :
  484. *****        a0 = BodyTekst
  485. *****       a1 = RetryCode
  486. *****       a2 = CancelCode
  487. ***** uit : sprong naar routine a1 of a2
  488. AutoReq
  489.     movem.l    a1/a2/a3/a6,-(SP)
  490.     push.l    a0        args
  491.     move.l    SP,a3
  492.     pea    .gadg(PC)
  493.     pea    .body(PC)
  494.     clr.l    -(SP)        titel
  495.     clr.l    -(SP)        flags
  496.     pea    [es_SIZEOF].w
  497.     move.l    WindowHD(a4),a0
  498.     move.l    sp,a1
  499.     sub.l    a2,a2
  500.     move.l    intbase(a4),a6
  501.     Lib    EasyRequestArgs
  502.     lea    es_SIZEOF+4(SP),SP
  503.     movem.l    (SP)+,a1/a2/a3/a6
  504.     tst.l    d0
  505.     bne.s    .yes
  506.     jmp    (a2)            doe CancelCode
  507. .yes    jmp    (a1)            doe RetryCode
  508.  
  509. .body    dc.b    "Can't open %s !",0
  510. .gadg    dc.b    'Opnieuw|Afbreken',0
  511.     even
  512.  
  513. ** open window met visualinfo/context
  514. ** in : a0 = newwindow
  515. ** uit: d0 = succes
  516. opengtwin
  517.     move.l    intbase(a4),a6
  518.     Lib    OpenWindow
  519.     move.l    d0,WindowHD(a4)
  520.     beq.b    .err
  521.     move.l    d0,a0
  522.     move.l    wd_WScreen(a0),a0
  523.     sub.l    a1,a1
  524.     move.l    gadbase(a4),a6
  525.     Lib    GetVisualInfoA
  526.     move.l    d0,vis_info(a4)
  527.     beq.w    novisinfo
  528.     lea    gadlist(a4),a0
  529.     Lib    CreateContext
  530.     move.l    d0,gadcont(a4)
  531.     beq.w    nocontext
  532. .err    rts
  533.  
  534. ****
  535. **** vraag instellingen van papier
  536. ****
  537. GetType    lea    newwin(PC),a0
  538.     bsr.b    opengtwin
  539.     tst.l    d0
  540.     beq.w    NoWin
  541.     bsr.w    MaakGetTypeGadgets
  542.     tst.l    d0
  543.     beq.w    nogadgets
  544. * gadgets toevoegen aan window *
  545.     bsr.w    addgtgads
  546. ** wachtlus
  547. gt_lus    move.l    WindowHD(a4),a0
  548.     move.l    86(a0),a0
  549.     move.l    4.w,a6
  550.     Lib    WaitPort
  551.     move.l    WindowHD(a4),a0
  552.     move.l    86(a0),a0
  553.     move.l    gadbase(a4),a6
  554.     Lib    GT_GetIMsg
  555.     move.l    d0,a1
  556.     move.l    im_Class(a1),d3        IDCMP-code
  557.     move    im_Code(a1),d2        special-data
  558.     move.l    im_IAddress(a1),a2    gadgetptr
  559.     Lib    GT_ReplyIMsg
  560.     cmp.l    #IDCMP_CLOSEWINDOW,d3    sluit symbool ??
  561.     beq.w    gt_Cancel
  562.     cmp.l    #IDCMP_GADGETUP,D3
  563.     beq.b    gt_Gadget
  564.     cmp.l    #IDCMP_GADGETDOWN,D3
  565.     BEQ.B    gt_Gadget
  566.     cmp.l    #IDCMP_REFRESHWINDOW,d3
  567.     beq.b    .refrwin
  568.     bra.b    gt_lus
  569.  
  570. .refrwin
  571.     move.l    WindowHD(a4),a0
  572.     Lib    GT_BeginRefresh
  573.     move.l    WindowHD(a4),a0
  574.     moveq    #1,d0
  575.     Lib    GT_EndRefresh
  576.     bra.b    gt_lus
  577.  
  578. gt_Gadget
  579.     move    gg_GadgetID(a2),d0    nummer
  580.  
  581.     cmp    #xPapID,d0
  582.     beq.b    gt_xpap
  583.     cmp    #yPapID,d0
  584.     beq.b    gt_ypap
  585.     cmp    #xEenhID,d0
  586.     beq.b    gt_xEenh
  587.     cmp    #yEenhID,d0
  588.     beq.b    gt_yEenh
  589.     cmp    #CancID,d0
  590.     beq.b    gt_Cancel        sluiten
  591.     cmp    #OkID,d0
  592.     beq.b    gt_Ok            sluiten & printen
  593.     cmp    #xInstID,d0
  594.     beq.w    gt_xInstellingen    xPrefs
  595.     cmp    #yInstID,d0
  596.     beq.w    gt_yInstellingen    yPrefs
  597.     
  598.     bra.w    gt_lus
  599.  
  600.  
  601. gt_xpap    addq    #1,d2
  602.     move.b    d2,xType
  603.     bra.w    gt_lus
  604. gt_ypap    addq    #1,d2
  605.     move.b    d2,yType
  606.     bra.w    gt_lus
  607.  
  608. gt_xEenh
  609.     move.l    gg_SpecialInfo(a2),a0
  610.     move.l    si_LongInt(a0),xEenheden
  611.     bra.w    gt_lus
  612. gt_yEenh
  613.     move.l    gg_SpecialInfo(a2),a0
  614.     move.l    si_LongInt(a0),yEenheden
  615.     bra.w    gt_lus
  616.  
  617. gt_Cancel
  618.     bsr.b    ClosegtWin
  619.     moveq    #0,d0            niet printen
  620.     rts
  621.  
  622. gt_Ok    bsr.b    ClosegtWin
  623.     moveq    #1,d0            wel printen
  624.     rts
  625.  
  626. ClosegtWin
  627.     move.l    WindowHD(a4),a0
  628.     move.l    4(a0),newwin
  629. CloseWin        * Sluit window, libs, etc. *
  630.     move.l    WindowHD(a4),a0
  631.     move.l    gadlist(a4),a1
  632.     moveq    #-1,d0        alle gadgets
  633.     move.l    intbase(a4),A6
  634.     Lib    RemoveGList    eerst gadgets uitzetten
  635. nogadgets
  636.     move.l    gadbase(a4),a6
  637.     move.l    gadlist(a4),a0
  638.     Lib    FreeGadgets    geef daarna gadgets vrij
  639. nocontext
  640.     move.l    gadbase(a4),a6
  641.     move.l    vis_info(a4),a0
  642.     Lib    FreeVisualInfo
  643. novisinfo        * sluit window *
  644.     move.l    WindowHD(a4),a0
  645.     move.l    intbase(a4),a6
  646.     Lib    CloseWindow
  647.     moveq    #0,d0        foutcode
  648.     rts
  649.  
  650. NoWin    lea    _window(PC),a0
  651.     lea    GetType(PC),a1
  652.     lea    .nowin(PC),a2
  653.     bra.w    AutoReq
  654. .nowin    moveq    #0,d0            niet printen
  655.     rts
  656.  
  657. gt_xInstellingen
  658.     lea    xDecbrd(pc),a2
  659.     bsr.b    ZetInstellingen
  660.     lea    xWinNaam(PC),a0
  661.     bsr.w    Instellingen
  662.     tst    d0
  663.     bne.s    .err            Cancel-gekozen
  664.     lea    xDecbrd(pc),a2
  665.     bsr.b    ZoekInstellingen
  666. .err    bra.w    GetType
  667.     
  668. gt_yInstellingen
  669.     lea    yDecbrd(pc),a2
  670.     bsr.b    ZetInstellingen
  671.     lea    yWinNaam(PC),a0
  672.     bsr.b    Instellingen
  673.     tst    d0
  674.     bne.s    .err            Cancel-gekozen
  675.     lea    yDecbrd(pc),a2
  676.     bsr.b    ZoekInstellingen    
  677. .err    bra.w    GetType
  678.  
  679. ZetInstellingen
  680.     lea    .tab2(PC),a1
  681.     moveq    #3,d2
  682. .1    move    (a1)+,d1
  683.     move.l    (a2)+,-2(a1,d1.w)
  684.     dbf    d2,.1
  685.     rts
  686.  
  687. .tab2    dr.w    Decades
  688.     dr.w    Primdkt
  689.     dr.w    Secdkt
  690.     dr.w    Terdkt
  691.  
  692. ZoekInstellingen
  693.     lea    .tab(PC),a0
  694.     moveq    #3,d0
  695. .1    move.w    (a0)+,d1
  696.     move.l    -2(a0,d1.w),(a2)+
  697.     dbf    d0,.1
  698.     rts
  699.  
  700. .tab    dr.w    Decades
  701.     dr.w    Primdkt
  702.     dr.w    Secdkt
  703.     dr.w    Terdkt
  704.  
  705.   if debug
  706. pdec    ext.l    d0
  707.     movem.l    d2/a2/a3,-(SP)
  708.     lea    .buffer(PC),a3
  709.     bsr    PrintInt
  710.     movem.l    (SP)+,d2/a2/a3
  711.     lea    .buffer(PC),a0
  712.     bra    print
  713.  
  714. .buffer    dcb.b    8,0
  715.  
  716. ;====== Function that will use the string '%ld' and makes an output
  717. ;====== in OutBuff (a3) in C-style
  718. PrintInt
  719.     move.l    4.w,a6
  720.     lea    _ld(PC),a0        our input-string
  721.     push.l    d0
  722.     move.l    SP,a1            our Arguments
  723.     lea    Function(PC),a2    ; our store-function; this one could be used
  724.                 ; to maintain a buffer and print it when it is
  725.                 ; full. However our function just copies.
  726. ;    lea    OutBuff(PC),a3        a3 = our outbuff
  727.     Lib    RawDoFmt
  728.     addq.l    #4,SP
  729.     rts            ; End of our program
  730.  
  731. ;=== in  : d0=byte to be printed
  732. ;===       a3=buffer
  733. ;=== out : a3=a3+1
  734. Function
  735.     move.b    d0,(a3)+
  736.     rts
  737.  
  738.   endif
  739.  
  740. addgtgads        * voeg gt-gadgets toe aan window *
  741.     move.l    WindowHD(a4),a0
  742.     move.l    gadlist(a4),a1        gadgets
  743.     moveq    #-1,d0            positie (achteraan)
  744.     moveq    #-1,d1            #gadgets (alle)
  745.     sub.l    a2,a2
  746.     move.l    intbase(a4),a6
  747.     Lib    AddGList
  748.     move.l    gadlist(a4),a0
  749.     MOVE.L    WindowHD(a4),a1
  750.     sub.l    a2,a2
  751.     moveq    #-1,d0            alle gadgets
  752.     Lib    RefreshGList
  753.     move.l    gadbase(a4),a6
  754.     move.l    WindowHD(a4),a0
  755.     sub.l    a1,a1
  756.     LibJ    GT_RefreshWindow
  757.  
  758. Instellingen
  759.     move.l    a0,InstelWin+nw_Title
  760.     move.l    WindowHD(a4),a0
  761.     move.l    4(a0),newwin
  762.     bsr.w    CloseWin        sluit en ruim op
  763.     move.l    intbase(a4),a6
  764.     lea    InstelWin(PC),a0
  765.     bsr.w    opengtwin
  766.     tst.l    d0
  767.     beq.w    .nowin
  768.     bsr.w    MaakInstGadgets
  769.     tst.l    d0
  770.     beq.w    nogadgets
  771. * gadgets toevoegen aan window *
  772.     bsr.b    addgtgads
  773. * verwerk boodschappen *
  774. .1    move.l    WindowHD(a4),a0
  775.     move.l    wd_UserPort(a0),a0
  776.     move.l    4.w,a6
  777.     Lib    WaitPort
  778.     move.l    WindowHD(a4),a0
  779.     move.l    wd_UserPort(a0),a0
  780.     move.l    gadbase(a4),a6
  781.     Lib    GT_GetIMsg
  782.     move.l    d0,a1
  783.     move.l    20(a1),d0
  784.     cmp.l    #IDCMP_CLOSEWINDOW,d0        sluit symbool ??
  785.     beq.b    .Cancel
  786.     cmp.l    #IDCMP_GADGETUP,d0
  787.     beq.b    .Gadget            handel gadget af
  788.     cmp.l    #IDCMP_REFRESHWINDOW,D0
  789.     beq.b    .refr    
  790.     Lib    GT_ReplyIMsg
  791.     bra.b    .1
  792.  
  793. .refr    Lib    GT_ReplyIMsg
  794.     move.l    WindowHD(a4),a0
  795.     Lib    GT_BeginRefresh
  796.     move.l    WindowHD(a4),a0
  797.     moveq    #1,d0
  798.     Lib    GT_EndRefresh
  799.     bra.b    .1
  800.  
  801. .Gadget    move.l    28(a1),a2        gadget naar a2
  802.     Lib    GT_ReplyIMsg
  803.     move    gg_GadgetID(a2),d0    nummer
  804.     beq.b    .num            getal ingetikt
  805.     cmp    #OkID,d0
  806.     beq.s    .ok
  807.     cmp    #CancID,d0
  808.     beq.s    .Cancel
  809.     bra.b    .1
  810.  
  811. .num    move.l    gg_UserData(a2),a0
  812.     move.l    gg_SpecialInfo(a2),a1
  813.     move.l    si_LongInt(a1),(a0)
  814.     bra.w    .1
  815.  
  816. .ok    move.l    WindowHD(a4),a0
  817.     move.l    4(a0),InstelWin
  818.     bsr.w    CloseWin
  819.     moveq    #0,d0
  820.     rts    
  821.     
  822. .Cancel    move.l    WindowHD(a4),a0
  823.     move.l    4(a0),InstelWin
  824.     bra.w    CloseWin
  825. .nowin
  826.     lea    _window(PC),a0
  827.     lea    Instellingen(PC),a1
  828.     lea    .canwin(PC),a2
  829.     bra.w    AutoReq
  830. .canwin    
  831.     moveq    #-1,d0            fout
  832.     rts
  833.  
  834.   if debug
  835. ;======= print string
  836. print    move.l    a0,d2
  837. .1    tst.b    (a0)+
  838.     bne.s    .1
  839.     move.l    a0,d3
  840.     sub.l    d2,d3
  841.     subq    #1,d3
  842.     move.l    ConHD(PC),d1
  843.     move.l    DosBase(a4),a6
  844.     LibJ    Write
  845.  
  846. ;=======    
  847. ;======= Printroutine
  848. ;=======
  849. PFLT    movem.l    d1-d6/a6,-(SP)
  850.     move.l    d0,d4
  851.     btst    #7,d0
  852.     beq    .2
  853.     lea    _Min(PC),a0
  854.     bsr    print
  855.     bclr    #7,d4
  856. .2    move.l    d4,d0
  857.     move.l    MathTR(a4),a6
  858.     jsr    Log10(a6)    ; 10 log nemen voor de exponent
  859.     move.l    Math(a4),a6
  860.     btst    #7,d0
  861.     beq    .6
  862.     move.l    #$800000c1,d1
  863.     jsr    Add(a6)
  864. .6    jsr    Fix(a6)
  865. .exppl    move.b    d0,EXP
  866.     neg.l    d0
  867.     addq.l    #4,d0
  868.     jsr    Flt(A6)
  869.     move.l    d0,d2
  870.     moveq    #10,d0
  871.     jsr    Flt(A6)
  872.     move.l    MathTR(a4),a6
  873.     move.l    d2,d1
  874.     jsr    Macht(A6)    ; vermenigvuldigen voor omzetten
  875.     move.l    Math(a4),a6
  876.     move.l    d4,d1
  877.     jsr    Mul(a6)
  878.     move.l    #$80000040,d1
  879.     jsr    Add(A6)
  880.     jsr    Fix(a6)        ; omzetten in een integer
  881.     move.l    d0,d1
  882.     moveq    #3,d0
  883.     lea    _dec+6(PC),a0    ; print fractie
  884. .1    divu    #10,d1
  885.     swap    d1
  886.     or.b    #$30,d1
  887.     move.b    d1,-(a0)
  888.     clr.w    d1
  889.     swap    d1
  890.     dbf    d0,.1
  891.     cmp.w    #10,d1
  892.     bmi    .nerr
  893.     moveq    #0,d0
  894.     move.b    EXP(PC),d0
  895.     addq    #1,d0
  896.     bra    .exppl
  897. .nerr    subq    #2,a0
  898.     move.b    d1,(a0)
  899.     or.w    #'0.',(a0)
  900.     lea    _dec+6(PC),a1
  901. .5    cmp.b    #$30,-(a1)
  902.     beq    .5
  903.     clr.b    1(A1)
  904.     cmp.b    #'.',(a1)
  905.     bne    .4
  906.     clr.b    (a1)
  907. .4    bsr    print        ; print Exponent
  908.     move.b    EXP(PC),d0
  909.     beq    .noexp
  910.     lea    _SHSH(PC),a0
  911.     bsr    print
  912.     moveq    #0,d0
  913.     move.b    EXP(PC),d0
  914.     bpl    .3
  915.     lea    _Min(PC),a0
  916.     bsr    print
  917.     moveq    #0,d0
  918.     sub.b    EXP(PC),d0
  919. .3    divu    #10,d0
  920.     lea    _dec+4(PC),a0
  921.     move.b    d0,(a0)
  922.     swap    d0
  923.     move.b    d0,1(A0)
  924.     or.w    #$3030,(A0)
  925.     bsr    print
  926. .noexp    lea    _LF(PC),a0    ; volgende regel
  927.     bsr    print
  928.     movem.l    (SP)+,d1-d6/a6
  929.     rts
  930.   endif
  931.  
  932. InstelWin
  933.     DC.W    120,25        X,Y
  934.     DC.W    300,100        Breedte,Hoogte.
  935.     DC.B    0        Letterkleur 0.
  936.     DC.B    1        Achtergrondkleur 1.
  937.     DC.L    IDCMP_CLOSEWINDOW!IDCMP_REFRESHWINDOW!BUTTONIDCMP
  938.     DC.L    WFLAG        Window-mogelijkheden.
  939.     DC.L    0        Gadgets.
  940.     DC.L    0        Grafisch.
  941.     DC.L    0        Adres van de titel van het window.
  942.     DC.L    0        Adres van het screen (0=WorkBench).(30)
  943.     DC.L    0        Adres van de bitmap (geen).        (34)
  944.     DC.W    0,0        Breedte/Hoogte minimaal.
  945.     DC.W    0,0        Breedte/Hoogte maximaal.
  946.     DC.W    1        Scherm-type : 1=WorkBench, 15=custom
  947.  
  948. PrefOffs    equ    168
  949.  
  950. Decades    dc.l    0
  951. Primdkt    dc.l    0
  952. Secdkt    dc.l    0
  953. Terdkt    dc.l    0
  954.  
  955. ***
  956. *** Maak Gadgets
  957. ***
  958. MaakInstGadgets
  959. * gadget 1 : integer-gadget: decades *
  960.     lea    in_newgad(PC),a1
  961.     move.l    vis_info(a4),gng_VisualInfo(a1)
  962.     move    #15,gng_TopEdge(a1)
  963.     move    #PrefOffs,gng_LeftEdge(a1)
  964.     move    #48,gng_Width(a1)
  965.     clr    gng_GadgetID(a1)
  966.     moveq    #PLACETEXT_LEFT,d0
  967.     move.l    d0,gng_Flags(a1)
  968.     lea    _decade(PC),a0
  969.     lea    Decades(PC),a2
  970.     bsr.w    in_intgadsh
  971.     beq.w    in_nogadgets
  972. * gadget 2 : integer-gadget: primair *
  973.     lea    _prim(PC),a0
  974.     lea    Primdkt(PC),a2
  975.     bsr.w    in_intgad
  976.     beq.w    in_nogadgets
  977. * gadget 3 : integer-gadget: secundair *
  978.     lea    _sec(PC),a0
  979.     lea    Secdkt(PC),a2
  980.     bsr.w    in_intgad
  981.     beq.w    in_nogadgets
  982. * gadget 4 : integer-gadget: tertair *
  983.     lea    _ter(PC),a0
  984.     lea    Terdkt(pc),a2
  985.     bsr.w    in_intgad    
  986.     beq.w    in_nogadgets
  987. * gadget 5 : button : Goed *
  988.     lea    in_newgad(PC),a1
  989.     add    #hgt+INTERHEIGHT,gng_TopEdge(a1)
  990.     move    #xOffs,gng_LeftEdge(a1)
  991.     move    #150-2*xOffs,gng_Width(a1)
  992.     move    #OkID,gng_GadgetID(a1)
  993.     lea    _goed(PC),a0
  994.     move.l    a0,gng_GadgetText(a1)
  995.     moveq    #PLACETEXT_IN,d0
  996.     move.l    d0,gng_Flags(a1)
  997.     move.l    gadcont(a4),a0
  998.     moveq    #BUTTON_KIND,d0
  999.     sub.l    a2,a2            taglist
  1000.     Lib    CreateGadgetA
  1001.     move.l    d0,gadcont(a4)
  1002.     beq.w    in_nogadgets
  1003. * gadget 6 : button : Cancel *
  1004.     lea    in_newgad(PC),a1
  1005.     move    #150+xOffs,gng_LeftEdge(a1)
  1006.     move    #CancID,gng_GadgetID(a1)
  1007.     lea    _cancel(PC),a0
  1008.     move.l    a0,gng_GadgetText(a1)
  1009.     move.l    gadcont(a4),a0
  1010.     moveq    #BUTTON_KIND,d0
  1011.     sub.l    a2,a2            taglist
  1012.     Lib    CreateGadgetA
  1013.     move.l    d0,gadcont(a4)
  1014.     beq.b    in_nogadgets
  1015. * gadget 7 : Text-gadget : mm *
  1016.     lea    in_newgad(pc),a1
  1017.     move    #PrefOffs+48,gng_LeftEdge(a1)
  1018.     move    #15,gng_TopEdge(a1)
  1019.     clr    gng_Width(a1)
  1020.     lea    _mm(PC),a0
  1021.     move.l    a0,gng_GadgetText(a1)
  1022.     moveq    #PLACETEXT_RIGHT,d0
  1023.     move.l    d0,gng_Flags(a1)
  1024.     move.l    gadcont(a4),a0
  1025.     moveq    #TEXT_KIND,d0
  1026.     sub.l    a2,a2
  1027.     Lib    CreateGadgetA
  1028.     move.l    d0,gadcont(a4)
  1029.     beq.b    in_nogadgets    
  1030. * gadget 8,9,10 : Text-gadget : prim/sec/ter-pixels *
  1031.     moveq    #3-1,d2
  1032. .1    lea    in_newgad(pc),a1
  1033.     add    #hgt+INTERHEIGHT,gng_TopEdge(a1)
  1034.     lea    _pixels(PC),a0
  1035.     move.l    a0,gng_GadgetText(a1)
  1036.     move.l    gadcont(a4),a0
  1037.     moveq    #TEXT_KIND,d0
  1038.     sub.l    a2,a2
  1039.     Lib    CreateGadgetA
  1040.     move.l    d0,gadcont(a4)
  1041.     dbeq    d2,.1
  1042. in_nogadgets
  1043.     rts
  1044. * integergadget, volgende regel, 4 letters/max
  1045. * in : a0 = tekst
  1046. *      a2 = variabele
  1047. in_intgad
  1048.     lea    in_newgad(PC),a1
  1049.     add    #hgt+INTERHEIGHT,gng_TopEdge(a1)
  1050. in_intgadsh        * speciaal voor decades *
  1051.     move.l    a0,gng_GadgetText(a1)
  1052.     move.l    a2,gng_UserData(a1)
  1053.     clr.l    -(sp)        tag_end
  1054.     pea    4.w
  1055.     push.l    #GTIN_MaxChars
  1056.     push.l    (a2)
  1057.     push.l    #GTIN_Number
  1058.     move.l    SP,a2            taglist
  1059.     move.l    gadcont(a4),a0
  1060.     moveq    #INTEGER_KIND,d0
  1061.     Lib    CreateGadgetA
  1062.     lea    5*4(SP),sp
  1063.     move.l    d0,gadcont(a4)
  1064.     rts
  1065.  
  1066. ** newgadget **
  1067. in_newgad
  1068.     dc.w    0,0        x/y
  1069.     dc.w    brd,hgt        brd/hgt
  1070.     dc.l    0        text
  1071.     dc.l    topaz8        textattr
  1072.     dc.w    0        ID
  1073.     dc.l    0        flags
  1074.     dc.l    0        vis_info
  1075.     dc.l    0        userdata
  1076.  
  1077.  
  1078. AbortX    equ    156
  1079. AbortY    equ    30
  1080.  
  1081. AbortWin
  1082.     DC.W    120,25        X,Y
  1083.     DC.W    AbortX+20,AbortY+22      Breedte,Hoogte.
  1084.     DC.B    0,1        Letterkleur/Achtergrondkleur 0/1.
  1085.     DC.L    CLOSEWINDOW!BUTTONIDCMP!IDCMP_REFRESHWINDOW
  1086.     DC.L    WFLAG        Window-mogelijkheden.
  1087.     DC.L    0        Gadgets.
  1088.     DC.L    0        Grafisch.
  1089.     DC.L    WindowTitel    Adres van de titel van het window.
  1090.     DC.L    0        Adres van het screen (0=WorkBench).(30)
  1091.     DC.L    0        Adres van de bitmap (geen).        (34)
  1092.     DC.W    0,0        Breedte/Hoogte minimaal.
  1093.     DC.W    0,0        Breedte/Hoogte maximaal.
  1094.     DC.W    1        Scherm-type : 1=WorkBench, 15=custom
  1095.  
  1096. topaz8    dc.l    topaznaam
  1097.     dc.w    8,0
  1098. topaz9    dc.l    topaznaam
  1099.     dc.w    9,0
  1100.         
  1101. newwin    DC.W    120,25        X,Y
  1102.     DC.W    350,129        Breedte,Hoogte.
  1103.     DC.B    0,1        Letterkleur 0/Achtergrondkleur 1.
  1104.     DC.L    CLOSEWINDOW!BUTTONIDCMP!MXIDCMP!IDCMP_REFRESHWINDOW
  1105.     DC.L    WFLAG        Window-mogelijkheden.
  1106.     DC.L    0        Gadgets.
  1107.     DC.L    0        Grafisch.
  1108.     DC.L    WindowTitel
  1109.     DC.L    0        Screen (0=WorkBench).(30)
  1110.     DC.L    0        bitmap (geen).         (34)
  1111.     DC.W    0,0        Breedte/Hoogte minimaal.
  1112.     DC.W    0,0        Breedte/Hoogte maximaal.
  1113.     DC.W    1        Scherm-type : 1=WorkBench, 15=custom
  1114.  
  1115. xOffs    equ    10
  1116. brd    equ    160
  1117. hgt    equ    12
  1118. yOffs    equ    xOffs+brd+10
  1119. numgads    equ    5
  1120.  
  1121. xPapID    equ    1
  1122. xEenhID    equ    2
  1123. xInstID    equ    3
  1124. OkID    equ    4
  1125. yPapID    equ    5
  1126. yEenhID    equ    6
  1127. yInstID    equ    7
  1128. CancID    equ    8
  1129.  
  1130.  
  1131. gt_MXList    dc.l    _log
  1132.         dc.l    _antilog    
  1133.         dc.l    _lincm
  1134.         dc.l    _linhalf
  1135.         dc.l    _linmm
  1136.         dc.l    0
  1137.  
  1138. xEenheden    dc.l    10
  1139. yEenheden    dc.l    10
  1140.  
  1141. ***
  1142. *** Maak Gadgets
  1143. ***
  1144. MaakGetTypeGadgets
  1145.     lea    gt_newgad(pc),a1
  1146.     move.l    vis_info(a4),gng_VisualInfo(a1)
  1147.     clr    gng_GadgetID(a1)
  1148.     moveq    #xOffs,d2
  1149.     move.b    xType(pc),d3
  1150.     lea    _xrichting(PC),a0
  1151.     move.l    xEenheden(PC),d0
  1152.     lea    _ok(pc),a3
  1153.     bsr.b    mg_kolomgads
  1154.     beq.s    .end
  1155.     lea    gt_newgad(pc),a1
  1156.     move    #yOffs,d2
  1157.     move.b    yType(pc),d3
  1158.     lea    _yrichting(PC),a0
  1159.     move.l    yEenheden(PC),d0
  1160.     lea    _cancel(pc),a3
  1161.     bsr.b    mg_kolomgads
  1162. .end    rts
  1163.  
  1164. mg_kolomgads    
  1165. * gadget 1 : Text-gadget : x/y-kolom *
  1166.     push.l    d0
  1167.     move    d2,gng_LeftEdge(a1)
  1168.     move.l    a0,gng_GadgetText(a1)
  1169.     move    #14,gng_TopEdge(a1)
  1170.     moveq    #PLACETEXT_IN,d0
  1171.     move.l    d0,gng_Flags(a1)
  1172.     move.l    gadcont(a4),a0
  1173.     moveq    #TEXT_KIND,d0
  1174.     sub.l    a2,a2
  1175.     Lib    CreateGadgetA
  1176.     move.l    d0,gadcont(a4)
  1177.     beq.w    mg_nogadgets    
  1178. * gadget 2 : MX-gadget : x/y-papiersoort *
  1179.     lea    gt_newgad(pc),a1
  1180.     add    #hgt,gng_TopEdge(a1)
  1181.     clr.l    gng_GadgetText(a1)
  1182.     addq    #1,gng_GadgetID(a1)
  1183.     moveq    #PLACETEXT_RIGHT,d0
  1184.     move.l    d0,gng_Flags(a1)
  1185.     move.l    gadcont(a4),a0
  1186.     moveq    #MX_KIND,d0
  1187.     clr.l    -(sp)
  1188.     moveq    #0,d1
  1189.     move.b    d3,d1
  1190.     subq    #1,d1
  1191.     push.l    d1
  1192.     push.l    #GTMX_Active
  1193.     pea    2.w
  1194.     push.l    #GTMX_Spacing
  1195.     pea    gt_MXList(PC)
  1196.     push.l    #GTMX_Labels
  1197.     MOVE.l    SP,a2            taglist
  1198.     Lib    CreateGadgetA
  1199.     lea    3*8+4(sp),sp
  1200.     move.l    d0,gadcont(a4)
  1201.     beq.w    mg_nogadgets    
  1202. * gadget 3 : integer-gadget: x/y-eenheden *
  1203.     lea    gt_newgad(PC),a1
  1204.     add    #5*10+INTERHEIGHT,gng_TopEdge(a1)
  1205.     moveq    #80,d0
  1206.     add    d2,d0
  1207.     move    d0,gng_LeftEdge(a1)
  1208.     move    #brd-80,gng_Width(a1)
  1209.     addq.w    #1,gng_GadgetID(a1)
  1210.     lea    _eenheden(PC),a0
  1211.     move.l    a0,gng_GadgetText(a1)
  1212.     moveq    #PLACETEXT_LEFT,d0
  1213.     move.l    d0,gng_Flags(a1)
  1214.     move.l    gadcont(a4),a0
  1215.     moveq    #INTEGER_KIND,d0
  1216.     move.l    (SP),d1
  1217.     clr.l    -(sp)        tag_end
  1218.     pea    4.w
  1219.     push.l    #GTIN_MaxChars
  1220.     push.l    d1        Eenheden-waarde
  1221.     push.l    #GTIN_Number
  1222.     move.l    SP,a2            taglist
  1223.     Lib    CreateGadgetA
  1224.     lea    5*4(SP),sp
  1225.     move.l    d0,gadcont(a4)
  1226.     beq.b    mg_nogadgets
  1227. * gadget 4 : button : x/y-instellingen *
  1228.     lea    gt_newgad(PC),a1
  1229.     add    #hgt+INTERHEIGHT,gng_TopEdge(a1)
  1230.     move    d2,gng_LeftEdge(a1)
  1231.     move    #brd,gng_Width(a1)
  1232.     addq    #1,gng_GadgetID(a1)
  1233.     lea    _instellingen(PC),a0
  1234.     move.l    a0,gng_GadgetText(a1)
  1235.     moveq    #PLACETEXT_IN,d0
  1236.     move.l    d0,gng_Flags(a1)
  1237.     move.l    gadcont(a4),a0
  1238.     moveq    #BUTTON_KIND,d0
  1239.     sub.l    a2,a2            taglist
  1240.     Lib    CreateGadgetA
  1241.     move.l    d0,gadcont(a4)
  1242.     beq.b    mg_nogadgets    
  1243. * gadget 5 : button : Printen/afbreken *
  1244.     lea    gt_newgad(PC),a1
  1245.     add    #hgt+INTERHEIGHT,gng_TopEdge(a1)
  1246.     addq    #1,gng_GadgetID(a1)
  1247.     move.l    a3,gng_GadgetText(a1)
  1248.     moveq    #PLACETEXT_IN,d0
  1249.     move.l    d0,gng_Flags(a1)
  1250.     move.l    gadcont(a4),a0
  1251.     moveq    #BUTTON_KIND,d0
  1252.     sub.l    a2,a2            taglist
  1253.     Lib    CreateGadgetA
  1254.     move.l    d0,gadcont(a4)
  1255. ;    beq    mg_nogadgets
  1256. mg_nogadgets
  1257.     addq    #4,sp
  1258.     rts
  1259.  
  1260.  
  1261. ** newgadget **
  1262. gt_newgad
  1263.     dc.w    0,0        x/y
  1264.     dc.w    brd,hgt        brd/hgt
  1265.     dc.l    0        text
  1266.     dc.l    topaz8        textattr
  1267.     dc.w    0        ID
  1268.     dc.l    0        flags
  1269.     dc.l    0        vis_info
  1270.     dc.l    0        userdata
  1271.  
  1272. **
  1273. ** VARIABELEN
  1274. **
  1275. _decade        dc.b    'Breedte van decades',0
  1276. _mm        dc.b    'mm',0
  1277. _pixels        dc.b    'pixels',0
  1278. _prim        dc.b    'Dikte hoofdlijnen',0
  1279. _sec        dc.b    'Dikte bijlijnen',0
  1280. _ter        dc.b    'Dikte mm-lijnen',0
  1281. _printen    dc.b    'Printen',0
  1282. _afbreken    dc.b    'afbreken',0
  1283. _ok        dc.b    'Print',0
  1284. _goed        dc.b    'Ok',0
  1285. _cancel        dc.b    'Cancel',0
  1286. _instellingen    dc.b    'Instellingen',0
  1287. _eenheden    dc.b    'Eenheden',0
  1288. _dikte        dc.b    'Dikte',0
  1289. _diktehalf    dc.b    'Dikte halve cm',0
  1290. _diktemm    dc.b    'Dikte mm',0
  1291. _seclog        dc.b    'Dikte overige',0
  1292. _log        dc.b    'logaritmisch',0
  1293. _lincm        dc.b    'lineair (1 cm)',0
  1294. _linhalf    dc.b    'lineair (½ cm)',0
  1295. _linmm        dc.b    'lineair (1 mm)',0
  1296. _antilog    dc.b    'anti-logaritmisch',0
  1297. _xrichting    dc.b    'X-richting :',0
  1298. _yrichting    dc.b    'Y-richting :',0
  1299. WindowTitel    dc.b    'GraphPaperPrint V1.1 by MVW © 1997',0
  1300. xWinNaam    dc.b    'X Instellingen',0
  1301. yWinNaam    dc.b    'Y Instellingen',0
  1302. topaznaam    dc.b    'topaz.font',0
  1303. bodytext    dc.b    "Can't get",0
  1304. _retry        dc.b    'Retry',0
  1305.     even
  1306.  
  1307.  
  1308. ***** zoek de hoogste waarde in een lijnenarray
  1309. ***** in  : a0 = array
  1310. ***** uit : d0.w = max
  1311. GetMax
  1312.     move    (a0)+,d1    aantal elementen
  1313.     move    (a0)+,d0    eerste max.
  1314.     subq    #2,d1
  1315. .lus    cmp    (a0)+,d0
  1316.     dblo    d1,.lus        verder indien d0 >= (a0)
  1317.     bhs.s    .ok
  1318.     move    -2(a0),d0
  1319.     dbf    d1,.lus
  1320. .ok    rts
  1321.  
  1322. ***** zoek de laagste waarde in een lijnenarray
  1323. ***** in  : a0 = array
  1324. ***** uit : d0.w = min
  1325. GetMin
  1326.     move    (a0)+,d1    aantal elementen
  1327.     move    (a0)+,d0    eerste min.
  1328.     subq    #2,d1
  1329. .lus    cmp    (a0)+,d0
  1330.     dbhi    d1,.lus        verder indien d0 =< (a0)
  1331.     bls.s    .ok
  1332.     move    -2(a0),d0
  1333.     dbf    d1,.lus
  1334. .ok    rts
  1335.  
  1336. ***** free lijnenarray
  1337. ***** in : a0 = array
  1338. FreeArray
  1339.     move.l    a0,a1
  1340.     moveq    #0,d0
  1341.     move    (a0),d0            aantal lijnen
  1342.     add.l    d0,d0
  1343.     addq.l    #2,d0            aantal bytes
  1344.     move.l    4.w,a6
  1345.     LibJ    FreeMem
  1346.  
  1347.   if debug
  1348. ****** a5 = ptr naar Array
  1349. ****** scratch a0/a1/d0-d4
  1350. PrintArray
  1351.     moveq    #0,d0
  1352.     move    (a5)+,d4
  1353.     subq    #1,d4
  1354. .xpr    move    (a5)+,d0
  1355.     bsr    pdec
  1356.     lea    _TAB(PC),a0
  1357.     bsr    print
  1358.     dbf    d4,.xpr
  1359.     lea    _LF(PC),a0
  1360.     bsr    print
  1361.     rts
  1362.   endif
  1363.  
  1364. ***** calc-papiersoort
  1365. ***** in : d0 = aantal eenheden
  1366. *****      d1 = dpi
  1367. *****      d2 = breedte primaire lijnen
  1368. *****      d3 = evt.breedte secundaire lijnen
  1369. *****      d4 = evt.breedte tertiaire lijnen
  1370. ***** uit : d0 = ptr naar lijnen-array
  1371. ***** lijnenarray : eerste woord = aantal lijnen
  1372. *****               volgende woorden = posities van de lijnen
  1373.  
  1374.  
  1375. ***** calc-halve-centimeter
  1376. ***** bereken lijnen met een afstand van 1 cm
  1377. ***** in : d0.w = aantal eenheden
  1378. *****       d1.w = dpi
  1379. *****       d2.l = breedte primaire lijnen (1 cm)
  1380. *****       d3.l = breedte secundaire lijnen (½ cm)
  1381. *****      d4.l = breedte tertiaire lijnen (1 mm)
  1382. ***** uit : d0 = ptr naar lijnen-array
  1383. MMREG    REG    d0-d7/a2/a3
  1384.  
  1385. CalcMM    ext.l    d1
  1386.     movem.l    MMREG,-(SP)
  1387.     move    d0,d5
  1388.     addq    #1,d0
  1389.     mulu    d2,d0        d0 = aantal hoofdlijnen
  1390.     mulu    d5,d3        d3 = aantal bijlijnen
  1391.     mulu    d5,d4
  1392.     asl.l    #3,d4        d4 = aantal mm-lijnen (8 x eenheden x breedte)
  1393.     add.l    d3,d0
  1394.     add.l    d4,d0        d0 = aantal lijnen
  1395.     move    d0,d4        d4=d0
  1396.     add.l    d0,d0
  1397.     addq.l    #2,d0        lengte
  1398.     moveq    #0,d1        eisen = geen
  1399.     move.l    4.w,a6
  1400.     lib    AllocMem
  1401.     push.l    d0
  1402.     beq.w    .nomem
  1403.     move.l    d0,a2
  1404.     move    d4,(a2)+    sla aantal lijnen op
  1405. ** bereken offsets
  1406.     move.l    12(SP),d0    d0 = breedte prim
  1407.     subq    #1,d0        (breedte - 1)
  1408.     move.l    Math(a4),a6
  1409.     lib    Flt
  1410.     move.l    #half,d1    (breedte - 1)/2
  1411.     lib    Mul
  1412.     move.l    d0,a3        a3 = prim. offset
  1413.     move.l    16(SP),d0    d0 = breedte sec
  1414.     subq    #1,d0
  1415.     lib    Flt
  1416.     move.l    #half,d1
  1417.     lib    Mul        (breedte - 1)/2
  1418.     move.l    d0,d5        d5 = sec. offset
  1419.     move.l    20(SP),d0    d0 = breedte ter
  1420.     subq    #1,d0
  1421.     Lib    Flt
  1422.     move.l    #half,d1
  1423.     Lib    Mul        (breedte - 1)/2
  1424.     move.l    d0,d6        d6 = ter. offset
  1425.     
  1426. ** kijk welke offset het grootste is; de grootste offset = begin-offset
  1427.     move.l    a3,d1        prim.offset
  1428.     lib    Cmp        sign( d1 - d0 )
  1429.     tst.l    d0
  1430.     bmi.s    .ter
  1431.     move.l    a3,d3        start-offset = prim. offset
  1432.     bra.s    .prim
  1433. .ter    move.l    d6,d3        start-offset = ter. offset
  1434. .prim    move.l    d5,d1
  1435.     move.l    d3,d0
  1436.     Lib    Cmp        sign( d1 - d0 )
  1437.     tst.l    d0
  1438.     bmi.s    .ok        -> start-offset = prim. of sec. offset
  1439.     move.l    d5,d3        start-offset = sec. offset
  1440. .ok    move.l    d3,d0
  1441.     move.l    #half,d1
  1442.     lib    Add
  1443.     move.l    d0,d3        start-offset met afronding
  1444.     move.l    a3,d0
  1445.     lib    Neg        inverteer prim.offset
  1446.     move.l    d0,a3
  1447.     move.l    d5,d0
  1448.     lib    Neg        inverteer sec. offset
  1449.     move.l    d0,d5
  1450.     move.l    d6,d0
  1451.     lib    Neg        inverteer ter. offset
  1452.     move.l    d0,d6
  1453. ** bereken het aantal punten per mm
  1454.     move.l    8(SP),d0    dpi.l
  1455.     move.l    Math(a4),a6
  1456.     lib    Flt
  1457.     move.l    #cmpinch,d1
  1458.     Lib    Mul
  1459.     move.l    #tiende,d1    d0 = punten per cm
  1460.     Lib    Mul
  1461.     move.l    d0,d7        d7 = dots per mm
  1462. ** vul de lijst in
  1463.     move.l    4(SP),d2
  1464.     subq    #1,d2        aantal eenheden -1
  1465. .lus            * prim.lijn
  1466.     move.l    d3,d0        beginwaarde
  1467.     move.l    a3,d1        prim.offset
  1468.     lib    Add
  1469.     lib    Fix
  1470.     move.l    12(SP),d1    breedte prim.lijn
  1471.     subq    #1,d1
  1472. .1      move      d0,(a2)+
  1473.       addq      #1,d0
  1474.       dbf      d1,.1
  1475.  
  1476.     bsr.b    mmlines        teken 4 millemeter-lijntjes
  1477.  
  1478.     move.l    d3,d0
  1479.     move.l    d7,d1
  1480.     Lib    Add        verhoog waarde met een mm
  1481.     move.l    d0,d3
  1482.             * sec.lijn
  1483.     move.l    d5,d1        sec. offset
  1484.     Lib    Add
  1485.     Lib    Fix
  1486.     move.l    16(SP),d1    breedte sec.lijn
  1487.     subq    #1,d1
  1488. .2      move      d0,(a2)+
  1489.       addq      #1,d0
  1490.       dbf      d1,.2
  1491.  
  1492.     bsr.b    mmlines        teken 4 millimeter-lijntjes
  1493.     move.l    d3,d0
  1494.     move.l    d7,d1
  1495.     Lib    Add        verhoog waarde met een mm
  1496.     move.l    d0,d3
  1497.  
  1498.     dbf    d2,.lus        volgende cm
  1499.  
  1500. ** laatste prim.lijn
  1501.     move.l    a3,d1        prim.offset
  1502.     lib    Add
  1503.     lib    Fix
  1504.     move.l    12(SP),d1    breedte prim.lijn
  1505.     subq    #1,d1
  1506. .3      move      d0,(a2)+
  1507.       addq      #1,d0
  1508.       dbf      d1,.3
  1509. .canmem
  1510.     pop.l    a0
  1511.     movem.l    (SP)+,MMREG
  1512.     move.l    a0,d0
  1513.     rts
  1514.  
  1515. .nomem    lea    _mem(PC),a0
  1516.     lea    .retmem(PC),a1
  1517.     lea    .canmem(PC),a2
  1518.     bra.w    AutoReq
  1519.  
  1520. .retmem    addq.l    #4,SP
  1521.     movem.l    (SP)+,MMREG
  1522.     bra.w    CalcMM
  1523.     
  1524. ***** 4x ter.lijn
  1525. mmlines    moveq    #3,d4
  1526. .1    move.l    d3,d0
  1527.     move.l    d7,d1        een mm
  1528.     Lib    Add        verhoog waarde met een mm
  1529.     move.l    d0,d3
  1530.     move.l    d6,d1        ter. offset
  1531.     Lib    Add
  1532.     Lib    Fix
  1533.     move.l    20(SP),d1    breedte ter.lijn
  1534.     subq    #1,d1
  1535. .2      move      d0,(a2)+
  1536.       addq      #1,d0
  1537.       dbf      d1,.2
  1538.     dbf    d4,.1
  1539.     rts
  1540.  
  1541.  
  1542. ***** calc-halve-centimeter
  1543. ***** bereken lijnen met een afstand van 1 cm
  1544. ***** in : d0.w = aantal eenheden
  1545. *****       d1.w = dpi
  1546. *****       d2.l = breedte primaire lijnen
  1547. *****       d3.l = breedte secundaire lijnen
  1548. ***** uit : d0 = ptr naar lijnen-array
  1549. HALFREG    REG    d0-d6/a2
  1550.  
  1551. CalcHalf
  1552.     ext.l    d1
  1553.     movem.l    HALFREG,-(SP)
  1554.     move    d0,d4
  1555.     addq    #1,d0
  1556.     mulu    d2,d0        d0 = aantal hoofdlijnen
  1557.     mulu    d3,d4        d4 = aantal bijlijnen
  1558.     add.l    d4,d0        d0 = totaal aantal lijnen
  1559.     move    d0,d4        d4=d0
  1560.     add.l    d0,d0
  1561.     addq.l    #2,d0        lengte
  1562.     moveq    #0,d1        eisen = geen
  1563.     move.l    4.w,a6
  1564.     lib    AllocMem
  1565.     push.l    d0
  1566.     beq.w    .nomem
  1567.     move.l    d0,a2
  1568.     move    d4,(a2)+    sla aantal lijnen op
  1569. ** bereken offsets
  1570.     move.l    12(SP),d0    d0 = breedte prim
  1571.     subq    #1,d0        (breedte - 1)
  1572.     move.l    Math(a4),a6
  1573.     lib    Flt
  1574.     move.l    #half,d1    (breedte - 1)/2
  1575.     lib    Mul
  1576.     move.l    d0,d4        d4 = prim. offset
  1577.     move.l    16(SP),d0    d0 = breedte sec
  1578.     subq    #1,d0
  1579.     lib    Flt
  1580.     move.l    #half,d1
  1581.     lib    Mul        (breedte - 1)/2
  1582.     move.l    d0,d5        d5 = sec. offset
  1583.     move.l    d4,d1        prim.offset
  1584. ** kijk welke offset het grootste is; de grootste offset = begin-offset
  1585.     lib    Cmp        sign( d1 - d0 )
  1586.     tst.l    d0
  1587.     bmi.s    .sec
  1588.     move.l    d4,d3        start-offset = prim. offset
  1589.     bra.s    .prim
  1590. .sec    move.l    d5,d3        start-offset = sec. offset
  1591. .prim    move.l    d3,d0
  1592.     move.l    #half,d1
  1593.     lib    Add
  1594.     move.l    d0,d3        start-offset met afronding
  1595.     move.l    d4,d0
  1596.     lib    Neg        inverteer prim.offset
  1597.     move.l    d0,d4
  1598.     move.l    d5,d0
  1599.     lib    Neg        inverteer sec. offset
  1600.     move.l    d0,d5
  1601. ** bereken het aantal punten per halve cm
  1602.     move.l    8(SP),d0    dpi.l
  1603.     move.l    Math(a4),a6
  1604.     lib    Flt
  1605.     move.l    #cmpinch,d1
  1606.     Lib    Mul
  1607.     move.l    #half,d1    d0 = punten per cm
  1608.     Lib    Mul
  1609.     move.l    d0,d6        d6 = dots per halve cm
  1610. ** vul de lijst in
  1611.     move.l    4(SP),d2
  1612.     subq    #1,d2        aantal eenheden -1
  1613. .lus            * prim.lijn
  1614.     move.l    d3,d0        beginwaarde
  1615.     move.l    d4,d1        prim.offset
  1616.     lib    Add
  1617.     lib    Fix
  1618.     move.l    12(SP),d1    breedte prim.lijn
  1619.     subq    #1,d1
  1620. .1      move      d0,(a2)+
  1621.       addq      #1,d0
  1622.       dbf      d1,.1
  1623.  
  1624.     move.l    d3,d0
  1625.     move.l    d6,d1
  1626.     Lib    Add        verhoog waarde met een halve cm
  1627.     move.l    d0,d3
  1628.             * sec.lijn
  1629.     move.l    d5,d1        sec. offset
  1630.     Lib    Add
  1631.     Lib    Fix
  1632.     move.l    16(SP),d1    breedte sec.lijn
  1633.     subq    #1,d1
  1634. .2      move      d0,(a2)+
  1635.       addq      #1,d0
  1636.       dbf      d1,.2
  1637.       
  1638.     move.l    d3,d0
  1639.     move.l    d6,d1
  1640.     Lib    Add        verhoog waarde met een halve cm
  1641.     move.l    d0,d3
  1642.     
  1643.     dbf    d2,.lus        volgende cm
  1644. ** laatste prim.lijn
  1645.     move.l    d4,d1        prim.offset
  1646.     lib    Add
  1647.     lib    Fix
  1648.     move.l    12(SP),d1    breedte prim.lijn
  1649.     subq    #1,d1
  1650. .3      move      d0,(a2)+
  1651.       addq      #1,d0
  1652.       dbf      d1,.3
  1653. .nomem
  1654.     pop.l    a0
  1655.     movem.l    (SP)+,HALFREG
  1656.     move.l    a0,d0
  1657.     rts
  1658.  
  1659.  
  1660. ***** calc-centimeter
  1661. ***** bereken lijnen met een afstand van 1 cm
  1662. ***** in : d0.w = aantal eenheden
  1663. *****      d1.w = dpi
  1664. *****      d2.l = breedte primaire lijnen
  1665. ***** uit : d0 = ptr naar lijnen-array
  1666. CENTREG    REG    d0-d4/a2
  1667.  
  1668. CalcCent
  1669.     ext.l    d1
  1670.     movem.l    CENTREG,-(SP)
  1671.     addq    #1,d0
  1672.     mulu    d2,d0        d0 = aantal lijnen
  1673.     move    d0,d3
  1674.     add.l    d0,d0
  1675.     addq.l    #2,d0        lengte
  1676.     moveq    #0,d1        eisen
  1677.     move.l    4.w,a6
  1678.     lib    AllocMem
  1679.     push.l    d0
  1680.     beq.b    .nomem
  1681.     move.l    d0,a2
  1682.     move    d3,(a2)+    sla aantal lijnen op
  1683.     move.l    8(SP),d0    dpi.l
  1684.     move.l    Math(a4),a6
  1685.     lib    Flt
  1686.     move.l    #cmpinch,d1
  1687.     Lib    Mul
  1688.     move.l    d0,d4        d4 = dots per cm
  1689.  
  1690.     move.l    4(SP),d2    aantal hokjes
  1691.     move.l    #half,d0    d0 = beginwaarde = 0(int)
  1692. .lus    move.l    d0,d3
  1693.     Lib    Fix        afronden
  1694.     move.l    12(SP),d1    dikte van de lijn
  1695.     subq    #1,d1
  1696. .lijn      move      d0,(a2)+    xpos++
  1697.       addq      #1,d0
  1698.       dbf      d1,.lijn
  1699.     move.l    d3,d0
  1700.     move.l    d4,d1
  1701.     Lib    Add
  1702.     dbf    d2,.lus
  1703. .nomem
  1704.     pop.l    a0
  1705.     movem.l    (SP)+,CENTREG
  1706.     move.l    a0,d0
  1707.     rts
  1708.  
  1709.  
  1710. ***** calc-log
  1711. ***** in : d0.w = aantal eenheden        = aantal decaden
  1712. *****      d1.l = breedte van eenheid in mm
  1713. *****      d2.w = dpi
  1714. *****      d3.w = breedte primaire lijnen    = begin van decade
  1715. *****      d4.w = breedte secundaire lijnen    = overige lijnen
  1716. ***** uit : d0 = ptr naar lijnen-array
  1717. LOGREG    REG    d0-d6/a2/a3
  1718.  
  1719. CalcLog    ext.l    d2
  1720.     movem.l    LOGREG,-(SP)
  1721.     addq    #1,d0
  1722.     mulu    d0,d3        aantal hoofdlijnen x breedte
  1723.     subq    #1,d0
  1724.     mulu    d4,d0        aantal decades x breedte bijlijn
  1725.     asl.l    #3,d0        x aantal bijlijnen per decade (8)
  1726.     add.l    d3,d0        d0 = aantal lijnen
  1727.     move    d0,d3
  1728.     add.l    d0,d0
  1729.     addq.l    #2,d0        lengte
  1730.     moveq    #0,d1        eisen
  1731.     move.l    4.w,a6
  1732.     lib    AllocMem
  1733.     push.l    d0
  1734.     beq.w    .nomem
  1735.     move.l    d0,a2
  1736.     move    d3,(a2)+    aantal lijnen opslaan
  1737. ** bereken offsets
  1738.     move.l    16(SP),d0
  1739.     subq    #1,d0        (breedte - 1)
  1740.     move.l    Math(a4),a6
  1741.     lib    Flt
  1742.     move.l    #half,d1    (breedte - 1)/2
  1743.     lib    Mul
  1744.     move.l    d0,d4        prim. offset
  1745.     move.l    20(SP),d0
  1746.     subq    #1,d0
  1747.     lib    Flt
  1748.     move.l    #half,d1
  1749.     lib    Mul        (breedte - 1)/2
  1750.     move.l    d0,d5        sec. offset
  1751.     move.l    d4,d1        prim.offset
  1752.     lib    Cmp        sign( d1 - d0 )
  1753.     tst.l    d0
  1754.     bmi.s    .sec
  1755.     move.l    d4,d3        start-offset
  1756.     bra.s    .prim
  1757. .sec    move.l    d5,d3
  1758. .prim    move.l    d3,d0
  1759.     move.l    #half,d1
  1760.     lib    Add
  1761.     move.l    d0,d3        start-offset met afronding
  1762.     move.l    d4,d0
  1763.     lib    Neg        inverteer prim.offset
  1764.     move.l    d0,d4
  1765.     move.l    d5,d0
  1766.     lib    Neg        inverteer sec. offset
  1767.     move.l    d0,d5
  1768. ** bereken het aantal punten per decade
  1769.     move.l    8(SP),d0    lengte in mm (d1.l)
  1770.     lib    Flt
  1771.     move.l    d0,d2
  1772.     move.l    12(SP),d0    dpi.l
  1773.     lib    Flt
  1774.     move.l    #cmpinch,d1
  1775.     Lib    Mul        d0 = #dots per cm
  1776.     move.l    d2,d1
  1777.     Lib    Mul        #dots per tien decades
  1778.     move.l    #tiende,d1
  1779.     Lib    Mul        d6 = #dots per decade
  1780.     move.l    d0,d6
  1781. ** vul de lijst in
  1782.     move.l    4(SP),d2
  1783.     subq    #1,d2        aantal eenheden -1
  1784. .primlus        * prim.lijn
  1785.     move.l    d3,d0        beginwaarde
  1786.     move.l    d4,d1        prim.offset
  1787.     lib    Add
  1788.     lib    Fix
  1789.     move.l    16(SP),d1    breedte prim.lijn
  1790.     subq    #1,d1
  1791. .1      move      d0,(a2)+
  1792.       addq      #1,d0
  1793.       dbf      d1,.1
  1794.     push.w    d2
  1795.     moveq    #8-1,d2
  1796.     lea    logtab+4(pc),a3
  1797. .seclus            * secundaire lijnen
  1798.     move.l    d6,d0
  1799.     move.l    (a3)+,d1
  1800.     lib    Mul
  1801.     move.l    d3,d1        offset
  1802.     lib    Add
  1803.     move.l    d5,d1        sec.offset
  1804.     lib    Add
  1805.     lib    Fix
  1806.     move.l    22(SP),d1    breedte sec.lijn
  1807.     subq    #1,d1
  1808. .2      move      d0,(a2)+
  1809.       addq      #1,d0
  1810.       dbf      d1,.2
  1811.     dbf    d2,.seclus
  1812.     pop.w    d2
  1813.     move.l    d6,d0
  1814.     move.l    d3,d1
  1815.     lib    Add        verhoog offset
  1816.     move.l    d0,d3
  1817.     dbf    d2,.primlus
  1818. ** laatste prim.lijn
  1819.     move.l    d4,d1        prim.offset
  1820.     lib    Add
  1821.     lib    Fix
  1822.     move.l    16(SP),d1    breedte prim.lijn
  1823.     subq    #1,d1
  1824. .3      move      d0,(a2)+
  1825.       addq      #1,d0
  1826.       dbf      d1,.3
  1827.     
  1828. .nomem    pop.l    a0
  1829.     movem.l    (SP)+,LOGREG
  1830.     move.l    a0,d0
  1831.     rts
  1832.  
  1833.  
  1834. ********
  1835. ******** maak de structuren om te tekenen
  1836. ********
  1837. InitGFX    moveq    #rp_SIZEOF,D0
  1838.     MOVE.l    #MEMF_PUBLIC!MEMF_CLEAR,D1
  1839.     move.l    4.w,a6
  1840.     Lib    AllocMem            geheugen voor rastport
  1841.     move.l    d0,rport2(a4)
  1842.     beq.w    norport
  1843.  
  1844.     moveq    #bm_SIZEOF,D0
  1845.     MOVE.l    #MEMF_PUBLIC!MEMF_CLEAR,D1
  1846.     Lib    AllocMem            geheugen voor bitmap
  1847.     move.l    d0,bmap2(a4)
  1848.     beq.w    nobmap
  1849.  
  1850.     move.l    gfxbase(a4),a6
  1851.     move.l    d0,a0
  1852.     moveq    #1,d0            1 bitplane
  1853.     moveq    #0,d1
  1854.     move    Width(a4),d1
  1855.     moveq    #0,d2
  1856.     move    Height(a4),d2
  1857.     Lib    InitBitMap            init bitmap
  1858.     moveq    #0,d0
  1859.     move    Width(a4),d0
  1860.     moveq    #0,d1
  1861.     move    Height(a4),d1
  1862.     Lib    AllocRaster            alloc plane1
  1863.     move.l    bmap2(a4),a0
  1864.     move.l    d0,bm_Planes(a0)
  1865.     beq.b    noraster
  1866.  
  1867.     move.l    rport2(a4),a1
  1868.     Lib    InitRastPort
  1869.     move.l    rport2(a4),a1            zet de bitmap in rastport
  1870.     move.l    bmap2(a4),rp_BitMap(a1)
  1871.  
  1872.     moveq    #1,d0
  1873.     move.l    rport2(a4),a1
  1874.     Lib    SetAPen
  1875.     
  1876.     moveq    #2,d0
  1877.     Lib    GetColorMap
  1878.     move.l    d0,cmap2(a4)
  1879.     beq.b    nocolor
  1880.  
  1881.     move.l    d0,a0
  1882.     push.l    d0
  1883.     moveq    #0,d0
  1884.     moveq    #15,d1
  1885.     moveq    #15,d2
  1886.     moveq    #15,d3
  1887.     Lib    SetRGB4CM    zet kleur 0 = wit
  1888.     pop.l    a0
  1889.     moveq    #1,d0
  1890.     moveq    #0,d1
  1891.     moveq    #0,d2
  1892.     moveq    #0,d3
  1893.     Lib    SetRGB4CM    zet kleur 1 = zwart
  1894.     rts
  1895. *****
  1896. ***** ruim alle teken-structuren op
  1897. *****
  1898. wisstruct
  1899.     move.l    cmap2(a4),a0
  1900.     move.l    gfxbase(a4),a6
  1901.     Lib    FreeColorMap
  1902. nocolor
  1903.     move.l    bmap2(a4),a0
  1904.     move.l    bm_Planes(a0),a0
  1905.     moveq    #0,d0
  1906.     move    Width(a4),d0
  1907.     moveq    #0,d1
  1908.     move    Height(a4),d1
  1909.     move.l    gfxbase(a4),a6
  1910.     Lib    FreeRaster
  1911. noraster
  1912.     move.l    bmap2(a4),a1
  1913.     moveq    #bm_SIZEOF,D0
  1914.     move.l    4.w,a6
  1915.     Lib    FreeMem
  1916. nobmap
  1917.     move.l    rport2(a4),a1
  1918.     moveq    #rp_SIZEOF,D0
  1919.     Lib    FreeMem
  1920. norport
  1921.     moveq    #-1,d0
  1922.     rts    
  1923.  
  1924. ********
  1925. ******** Open de printer en init variabelen als PD, PED etc.
  1926. ********
  1927. InitPrinter    
  1928.     sub.l    a1,a1
  1929.     move.l    4.w,a6
  1930.     Lib    FindTask        onze task zoeken
  1931.     
  1932.     lea    wrep(a4),a1
  1933.     move.l    d0,$10(a1)
  1934.     Lib    AddPort            reply-port toevoegen
  1935.  
  1936.     moveq    #-1,d0
  1937.     Lib    AllocSignal
  1938.     move.b    d0,wrep+MP_SIGBIT(a4)    zet sigbit
  1939.     move.l    Signals(a4),d1
  1940.     bset    d0,d1
  1941.     move.l    d1,Signals(a4)        zet bit in signals
  1942.     
  1943.     lea    PrtIO(a4),a1
  1944.     lea    wrep(a4),a0
  1945.     move.l    a0,14(a1)        reply-port
  1946.     moveq    #0,d0            device 0
  1947.     moveq    #0,d1            geen vlaggen
  1948.     lea    printer(PC),a0
  1949.     Lib    OpenDevice        printer.dev openen
  1950.     tst.l    d0
  1951.     bne.b    .noprt            Openingsfout -> exit
  1952.  
  1953.     lea    PrtIO(a4),a0
  1954.     move.l    IO_DEVICE(a0),PD(a4)
  1955.     move.l    PD(a4),a1
  1956.     move.l    pd_SegmentData(a1),a1
  1957.     lea    ps_PED(a1),a1
  1958.     move.l    a1,PED(a4)
  1959.     move    ped_NumRows(a1),Height(a4)        hoogte vd. rastport
  1960.     
  1961.     move.l    PD(a4),a1                stel prefs in
  1962.     lea    pd_Preferences(a1),a1
  1963.     move    #IMAGE_POSITIVE,pf_PrintImage(a1)    positief
  1964.     move    #ASPECT_HORIZ,pf_PrintAspect(a1)    horizontaal
  1965.     move    #SHADE_BW,pf_PrintShade(a1)        zwart/wit
  1966.     rts
  1967.  
  1968. .noprt    bsr.w    remprt            verwijder reply-port
  1969.     moveq    #1,d0            foutcode
  1970.     rts
  1971.  
  1972. ******
  1973. ****** Dump de rastport
  1974. ******
  1975. ** in  : d0.w = hoogte
  1976. ** uit : d0.b = errorcode
  1977. DumpDeel
  1978.     lea    PrtIO(a4),a1
  1979.     move    #PRD_DUMPRPORT,IO_COMMAND(a1)    commando (dump scherm)
  1980.     lea    32(a1),a0
  1981.     move.l    rport2(a4),(a0)+    ; 32 rastport
  1982.     move.l    cmap2(a4),(a0)+        ; 36 colormap
  1983.     clr.l    (a0)+            ; 40 (viewport)modes (geen)
  1984.     clr.l    (a0)+            ; 44 scrX,scrY
  1985.     move    Width(a4),d1
  1986.     move    d1,(a0)+        ; 48 breedte
  1987.     move    d0,(a0)+        ; 50 hoogte
  1988.     ext.l    d1
  1989.     ext.l    d0
  1990.     move.l    d1,(a0)+        ; 52 io_DestCols
  1991.     move.l    d0,(a0)+        ; 56 io_DestRows
  1992.  
  1993.     move    #SPECIAL_NOFORMFEED,io_Special(a1)    ; geen special
  1994.     move.l    4.w,a6
  1995.     Lib    SendIO            ; print rastport
  1996.  
  1997. .wait    move.l    Signals(a4),d0
  1998.     move.l    4.w,a6
  1999.     Lib    Wait
  2000.     move.b    wrep+MP_SIGBIT(A4),D1
  2001.     btst    d1,d0
  2002.     bne.s    .prtio
  2003.     move.l    WindowHD(a4),a0
  2004.     move.l    wd_UserPort(a0),a0
  2005.     move.b    MP_SIGBIT(A0),D1
  2006.     btst    d1,d0
  2007.     bne.s    .aborted    
  2008. .prtio    lea    wrep(a4),a0
  2009.     Lib    GetMsg
  2010.     tst.l    d0
  2011.     beq.s    .wait
  2012.     lea    PrtIO(a4),a1
  2013.     move.b    IO_ERROR(a1),d0
  2014.     rts
  2015.  
  2016. .aborted        * afgebroken of refresh *
  2017.     move.l    gadbase(a4),a6
  2018.     Lib    GT_GetIMsg
  2019.     move.l    d0,a1
  2020.     tst.l    d0
  2021.     beq.b    .wait        geen msg
  2022.     move.l    im_Class(a1),d2        IDCMP-code
  2023.     Lib    GT_ReplyIMsg
  2024.     cmp.l    #IDCMP_REFRESHWINDOW,d2
  2025.     beq.b    .refrwin
  2026. * afgebroken *
  2027.     lea    PrtIO(a4),a1
  2028.     move.l    4.w,a6
  2029.     Lib    AbortIO
  2030.     move.b    #PDERR_CANCEL,d0    ge'cancel'd
  2031.     rts
  2032. .refrwin        * refresh window *
  2033.     move.l    WindowHD(a4),a0
  2034.     Lib    GT_BeginRefresh
  2035.     move.l    WindowHD(a4),a0
  2036.     moveq    #1,d0
  2037.     Lib    GT_EndRefresh
  2038.     bra.b    .wait
  2039.  
  2040.     
  2041. ******
  2042. ****** sluit de printer
  2043. ******
  2044. ClosePrt
  2045.     lea    PrtIO(a4),a1
  2046.     move.l    4.w,a6
  2047.     Lib    CloseDevice        sluit printer
  2048. remprt
  2049.     moveq    #0,d0
  2050.     move.b    wrep+MP_SIGBIT(A4),D0
  2051.     move.l    4.w,a6
  2052.     Lib    FreeSignal
  2053.     lea    wrep(a4),a1
  2054.     Lib    RemPort            verwijder poort
  2055.     rts
  2056.  
  2057.  
  2058. hokx = 10    ; tien hokjes breed
  2059. hoky = 7    ; 7 hokjes hoog
  2060. linlin    = 0    print dubbel-lineair ?
  2061. loglog    = 1    print dubbel-logaritmisch ?
  2062.  
  2063.  
  2064. ***
  2065. *** Maak Gadgets
  2066. ***
  2067. MaakAbortGadgets
  2068. * gadget 1 : button: afbreken *
  2069.     lea    ab_newgad(PC),a1
  2070.     move.l    vis_info(a4),gng_VisualInfo(a1)
  2071.     move.l    gadcont(a4),a0
  2072.     moveq    #BUTTON_KIND,d0
  2073.     sub.l    a2,a2            taglist
  2074.     Lib    CreateGadgetA
  2075.     move.l    d0,gadcont(a4)
  2076.     rts
  2077.  
  2078. ** newgadget **
  2079. ab_newgad
  2080.     dc.w    10,15        x/y
  2081.     dc.w    AbortX,AbortY    brd/hgt
  2082.     dc.l    _afbreken    text
  2083.     dc.l    topaz9        textattr
  2084.     dc.w    0        ID
  2085.     dc.l    PLACETEXT_IN    flags
  2086.     dc.l    0        vis_info
  2087.     dc.l    0        userdata
  2088.     
  2089. *******
  2090. ******* Het hoofdprogramma
  2091. *******    
  2092. main    bsr.w    GetType
  2093.     tst    d0
  2094.     beq.s    .end
  2095. .retaw    lea    AbortWin(PC),a0
  2096.     bsr.w    opengtwin
  2097.     tst.l    d0
  2098.     beq.b    .nowin            geen window !! ->
  2099.     bsr.b    MaakAbortGadgets
  2100.     tst.l    d0
  2101.     beq.b    .noabgadgets
  2102. * gadgets toevoegen aan window *
  2103.     bsr.w    addgtgads
  2104. * print pagina *
  2105.     move.l    WindowHD(a4),a0
  2106.     moveq    #0,d0
  2107.     move.l    wd_UserPort(a0),a0
  2108.     move.b    MP_SIGBIT(A0),D1
  2109.     bset    d1,d0
  2110.     move.l    d0,Signals(a4)
  2111.     bsr.s    printpaper
  2112. .noabgadgets
  2113.     move.l    WindowHD(a4),a0
  2114.     move.l    4(a0),AbortWin
  2115.     bsr.w    CloseWin
  2116.     bra.b    main
  2117. .end    rts
  2118.  
  2119. .nowin    lea    _window(PC),a0
  2120.     lea    .retaw(PC),a1
  2121.     lea    .end(PC),a2
  2122.     bra.w    AutoReq
  2123.  
  2124. printpaper
  2125.     bsr.w    InitPrinter        installeer de printer
  2126.     tst.b    d0
  2127.     bne.b    .noprt
  2128. .retmem1
  2129.     moveq    #0,d0
  2130.     move.b    xType(pc),d0
  2131.     add    d0,d0
  2132.     add    .xpaptab-2(PC,d0.w),d0
  2133.     jsr    .xpaptab-2(PC,d0.w)
  2134.     tst.l    d0
  2135.     beq.b    .nomem1
  2136.     move.l    d0,a2            a2 = array met x-pos
  2137. .retmem2
  2138.     moveq    #0,d0
  2139.     move.b    yType(pc),d0
  2140.     add    d0,d0
  2141.     add    .ypaptab-2(PC,d0.w),d0
  2142.     jsr    .ypaptab-2(PC,d0.w)
  2143.     tst.l    d0
  2144.     beq.b    .nomem2
  2145.     move.l    d0,a3            a3 = array met y-pos
  2146.     bra.s    .print
  2147. .xpaptab
  2148.     dr.w    xLogPapier
  2149.     dr.w    xALogPapier
  2150.     dr.w    xLincmPapier
  2151.     dr.w    xLinhalfPapier
  2152.     dr.w    xLinmmPapier
  2153. .ypaptab
  2154.     dr.w    yLogPapier
  2155.     dr.w    yALogPapier
  2156.     dr.w    yLincmPapier
  2157.     dr.w    yLinhalfPapier
  2158.     dr.w    yLinmmPapier    
  2159.  
  2160. .print    
  2161.   if debug    
  2162.     lea    _xpos(PC),a0
  2163.     bsr    print
  2164.     move.l    a2,a5
  2165.     bsr    PrintArray
  2166.     lea    _ypos(PC),a0
  2167.     bsr    print
  2168.     move.l    a3,a5
  2169.     bsr    PrintArray
  2170.   endif
  2171.       move.l    a2,a0
  2172.       bsr.w    GetMax
  2173.       addq    #1,d0
  2174.       move    d0,Width(a4)
  2175.       
  2176. .retGFX    bsr.w    InitGFX            maak teken-structuren
  2177.     tst    d0
  2178.     bne.b    .nogfx
  2179.     bsr.w    PrintLijnen        print de tekening
  2180.  
  2181.     bsr.w    wisstruct        verwijder teken-structuren
  2182. .GFXcan
  2183.     move.l    a3,a0
  2184.     bsr.w    FreeArray        geef lijnenarray vrij
  2185. .canmem2    
  2186.     move.l    a2,a0
  2187.     bsr.w    FreeArray        geef lijnenarray vrij
  2188. .canmem1
  2189.     bsr.w    ClosePrt        sluit de printer    
  2190. .ex    rts
  2191.  
  2192. .noprt
  2193.     lea    printer(PC),a0        tekst
  2194.     lea    printpaper(PC),a1    retry
  2195.     lea    .ex(PC),a2        cancel
  2196.     bra.w    AutoReq
  2197. .nomem1
  2198.     lea    _mem(PC),a0
  2199.     lea    .retmem1(PC),a1
  2200.     lea    .canmem1(PC),a2
  2201.     bra.w    AutoReq
  2202. .nomem2
  2203.     lea    _mem(PC),a0
  2204.     lea    .retmem2(PC),a1
  2205.     lea    .canmem2(PC),a2
  2206.     bra.w    AutoReq
  2207. .nogfx
  2208.     lea    _noGFXMem(PC),a0
  2209.     lea    .retGFX(PC),a1
  2210.     lea    .GFXcan(PC),a2
  2211.     bra.w    AutoReq
  2212.         
  2213. * log in x-richting
  2214. xLogPapier
  2215.     move.l    xEenheden(PC),d0    #decaden
  2216.     move.l    xDecbrd(pc),d1        aantal mm per decade
  2217.     move.l    PED(a4),a1
  2218.     move    ped_XDotsInch(a1),d2    xdpi
  2219.     move.l    xPrimdkt(pc),d3        prim.dikte
  2220.     move.l    xSecdkt(pc),d4        sec. dikte
  2221.     bsr.w    CalcLog
  2222.     rts
  2223.     
  2224. * log in y-richting
  2225. yLogPapier
  2226.     move.l    yEenheden(PC),d0    #decaden
  2227.     move.l    yDecbrd(pc),d1        aantal mm per decade
  2228.     move.l    PED(a4),a1
  2229.     move    ped_YDotsInch(a1),d2    ydpi
  2230.     move.l    yPrimdkt(pc),d3        prim.dikte
  2231.     move.l    ySecdkt(pc),d4        sec. dikte
  2232.     bsr.w    CalcLog
  2233.     rts
  2234.  
  2235. * Antilog in x-richting
  2236. xALogPapier
  2237.     bsr.b    xLogPapier
  2238.     tst.l    d0
  2239.     beq.b    .nomem
  2240.     push.l    d0
  2241.     move.l    d0,a0
  2242.     bsr.w    GetMax
  2243.     move.l    (SP),a0
  2244.     move    (a0)+,d1
  2245.     subq    #1,d1
  2246. .1    move    d0,d2            d0 = max
  2247.     sub    (a0),d2
  2248.     move    d2,(a0)+        (a0) = max - (a0)
  2249.     dbf    d1,.1
  2250.     pop.l    d0
  2251. .nomem    rts
  2252.  
  2253. * Antilog in y-richting
  2254. yALogPapier
  2255.     bsr.b    yLogPapier
  2256.     tst.l    d0
  2257.     beq.b    .nomem
  2258.     push.l    d0
  2259.     move.l    d0,a0
  2260.     bsr.w    GetMax
  2261.     move.l    (SP),a0
  2262.     move    (a0)+,d1
  2263.     subq    #1,d1
  2264. .1    move    d0,d2            d0 = max
  2265.     sub    (a0),d2
  2266.     move    d2,(a0)+        (a0) = max - (a0)
  2267.     dbf    d1,.1
  2268.     pop.l    d0
  2269. .nomem    rts
  2270.  
  2271. * lin cm in x-richting
  2272. xLincmPapier
  2273.     move.l    xEenheden(PC),d0
  2274.     move.l    PED(a4),a1
  2275.     move    ped_XDotsInch(a1),d1    xdpi
  2276.     move.l    xPrimdkt(pc),d2        breedte van de lijnen
  2277.     bsr.w    CalcCent
  2278.     rts
  2279.     
  2280. * lin cm in y-richting
  2281. yLincmPapier
  2282.     move.l    yEenheden(PC),d0
  2283.     move.l    PED(a4),a1
  2284.     move    ped_YDotsInch(a1),d1    ydpi
  2285.     move.l    yPrimdkt(pc),d2        breedte van de lijnen
  2286.     bsr.w    CalcCent
  2287.     rts
  2288.  
  2289. * lin halve cm in x-richting
  2290. xLinhalfPapier
  2291.     move.l    xEenheden(PC),d0
  2292.     move.l    PED(a4),a1
  2293.     move    ped_XDotsInch(a1),d1    xdpi
  2294.     move.l    xPrimdkt(pc),d2        breedte van de lijnen
  2295.     move.l    xSecdkt(PC),d3
  2296.     bsr.w    CalcHalf
  2297.     rts
  2298.  
  2299. * lin halve cm in y-richting
  2300. yLinhalfPapier
  2301.     move.l    yEenheden(PC),d0
  2302.     move.l    PED(a4),a1
  2303.     move    ped_YDotsInch(a1),d1    ydpi
  2304.     move.l    yPrimdkt(pc),d2        breedte van de lijnen
  2305.     move.l    ySecdkt(PC),d3
  2306.     bsr.w    CalcHalf
  2307.     rts
  2308.  
  2309. * lin mm in x-richting
  2310. xLinmmPapier
  2311.     move.l    xEenheden(PC),d0
  2312.     move.l    PED(a4),a1
  2313.     move    ped_XDotsInch(a1),d1    xdpi
  2314.     move.l    xPrimdkt(pc),d2        breedte van de lijnen
  2315.     move.l    xSecdkt(PC),d3
  2316.     move.l    xTerdkt(PC),d4
  2317.     bsr.w    CalcMM
  2318.     rts
  2319.  
  2320. * lin mm in y-richting
  2321. yLinmmPapier
  2322.     move.l    yEenheden(PC),d0
  2323.     move.l    PED(a4),a1
  2324.     move    ped_YDotsInch(a1),d1    ydpi
  2325.     move.l    yPrimdkt(pc),d2        breedte van de lijnen
  2326.     move.l    ySecdkt(PC),d3
  2327.     move.l    yTerdkt(PC),d4
  2328.     bsr.w    CalcMM
  2329.     rts
  2330.     
  2331. *******
  2332. ******* Print de lijnen zoals aangegeven in de twee lijnenarrays
  2333. ******* in : a2 = (xpos) verticale lijnen-array
  2334. *******      a3 = (ypos) horizontale lijnen-array
  2335. *******
  2336. PRINTREG    REG    D2-D4/A2/A3
  2337.  
  2338. PrintLijnen
  2339.     movem.l    PRINTREG,-(SP)
  2340.         
  2341.     move.l    a3,a0
  2342.     bsr.w    GetMax
  2343.     move    d0,d4            max.y
  2344.  
  2345. .volg    move    d4,d3            d4 = hoogste waarde te printen
  2346.     sub    Height(a4),d3        - hoogte
  2347.     addq    #1,d3            d3 = laagste waarde te printen
  2348.  
  2349.     moveq    #0,d0
  2350.     move.l    rport2(a4),a1
  2351.     move.l    gfxbase(a4),a6
  2352.     Lib    SetRast            maak veld schoon
  2353.     
  2354.     move.l    a2,a0
  2355.     bsr.b    DrawVert        teken lijnen
  2356.     move.l    a3,a0
  2357.     bsr.b    DrawHoriz
  2358.     
  2359.     move    Height(a4),d0        standaard hoogte
  2360.     cmp    d0,d4
  2361.     bcc.s    .1
  2362.     move    d4,d0            laatste regel is korter
  2363. .1    bsr.w    DumpDeel        print regel
  2364.     tst.b    d0
  2365.     bne.b    .perror
  2366.  
  2367.     sub    Height(a4),d4
  2368.     bcc.b    .volg            volgende regel
  2369.  
  2370. .perror    movem.l    (SP)+,PRINTREG
  2371.     RTS
  2372.  
  2373. DrawVert
  2374.     push.l    a2
  2375.     move.l    a0,a2
  2376.     move    (a2)+,d2
  2377.     subq    #1,d2
  2378. .lus    moveq    #0,d0
  2379.     move    (a2),d0        xpos
  2380.     moveq    #0,d1        ypos
  2381.     move.l    rport2(a4),a1
  2382.     Lib    Move
  2383.  
  2384.     moveq    #0,d0
  2385.     move    (a2)+,d0    xpos
  2386.     tst    d3
  2387.     bmi.b    .spec
  2388.     moveq    #0,d1
  2389.     move    Height(a4),d1
  2390.     subq    #1,d1        ypos
  2391.     bra.b    .ok
  2392. .spec    moveq    #0,d1
  2393.     move    Height(a4),d1    (hoogte-1 )+(d3) (d3 < 0)
  2394.     subq    #1,d1
  2395.     add    d3,d1        ypos
  2396. .ok    Lib    Draw
  2397.     dbf    d2,.lus
  2398.     pop.l    a2
  2399.     rts
  2400.  
  2401. DrawHoriz
  2402.     push.l    a2
  2403.     move.l    a0,a2
  2404.     move    (a2)+,d2
  2405.     subq    #1,d2
  2406. .lus    moveq    #0,d1
  2407.     move    (a2)+,d1    ypos
  2408.     cmp    d4,d1
  2409.     bgt.b    .nodraw        (ypos > max) ->
  2410.     cmp    d3,d1
  2411.     blt.b    .nodraw        (ypos < min) ->
  2412.     sub    d4,d1
  2413.     neg    d1
  2414.     moveq    #0,d0        xpos
  2415.     Lib    Move
  2416.     moveq    #0,d1
  2417.     move    -2(a2),d1
  2418.     sub    d4,d1
  2419.     neg    d1
  2420.     moveq    #0,d0
  2421.     move    Width(a4),d0
  2422.     Lib    Draw
  2423. .nodraw    
  2424.     dbf    d2,.lus
  2425.     pop.l    a2
  2426.     rts    
  2427.     
  2428.   if debug
  2429. ConHD        dc.l    0
  2430. _dec        dc.b    '0.0000',0
  2431. EXP        dc.b    0
  2432. ConName        dc.b    'CON:10/10/510/200/Uitvoer-Window',0
  2433. _LF        dc.b    10,0
  2434. _TAB        dc.b    9,0
  2435. _TVV        dc.b    ' < Return voor verder >',0
  2436. _BINEXP        dc.b    'DEC',0
  2437. _SHSH        dc.b    '+E',0
  2438. _Punt        dc.b    '.',0
  2439. _Buff        dc.b    ' ',0
  2440. _Min        dc.b    '-',0
  2441. _NoMath        dc.b    "Can't open mathffp.library"
  2442. _NoMathTR    dc.b    "Can't open mathtrans.library"
  2443.   endif
  2444. dosnaam        DOSNAME
  2445. intuition    INTNAME
  2446. graphics    GRAFNAME
  2447. iconnaam    dc.b    'icon.library',0
  2448. MathName    dc.b    'mathffp.library',0
  2449. MathTRName    dc.b    'mathtrans.library',0
  2450. gadnaam        dc.b    'gadtools.library',0        
  2451. _window        dc.b    'window',0
  2452. _mem        dc.b    'memory',0
  2453. _noGFXMem    dc.b    'GFX-memory',0
  2454. printer        dc.b    'printer.device',0
  2455. _xpos        dc.b    'X-posities :',10,0
  2456. _ypos        dc.b    'Y-posities :',10,0
  2457. _ld        dc.b    '%ld',0
  2458.     even
  2459.     
  2460. logtab    dc.l    $0            log(1)=0
  2461.     dc.l    $9a209b3f        log(2)
  2462.     dc.l    $f4493d3f        log(3)
  2463.     dc.l    $9a209b40        log(4)=2*log(2)
  2464.     dc.l    $b2efb240
  2465.     dc.l    $c734ec40
  2466.     dc.l    $d8585740
  2467.     dc.l    $e730e840
  2468.     dc.l    $f4493d40        log(9)=2*log(3)
  2469.     dc.l    $80000041        log(10)=1
  2470.  
  2471. * instellingen
  2472. xDecbrd        dc.l    25    breedte van een decade in mm
  2473. xPrimdkt    dc.l    2    dikte hoofdlijnen in pixels
  2474. xSecdkt        dc.l    1      "    bij-  "        "
  2475. xTerdkt        dc.l    1      "    mm-  "        "
  2476. yDecbrd        dc.l    25
  2477. yPrimdkt    dc.l    3
  2478. ySecdkt        dc.l    1
  2479. yTerdkt        dc.l    1
  2480.  
  2481. xType        dc.b    1
  2482. yType        dc.b    1
  2483.  
  2484. ;======= Variabelen
  2485.     rsreset
  2486. DosBase        rs.l    1
  2487. intbase        rs.l    1
  2488. gfxbase        rs.l    1
  2489. gadbase        rs.l    1
  2490. WindowHD    rs.l    1
  2491. vis_info    rs.l    1    visual-info
  2492. gadlist        rs.l    1    eerste gadget
  2493. gadcont        rs.l    1    gadtools-context
  2494. Math        rs.l    1
  2495. MathTR        rs.l    1
  2496. rport2        rs.l    1
  2497. bmap2        rs.l    1
  2498. cmap2        rs.l    1
  2499. Width        rs.w    1
  2500. Height        rs.w    1
  2501. Signals        rs.l    1
  2502. * printer
  2503. PD        rs.l    1
  2504. PED        rs.l    1
  2505. wrep        rs.b    MP_SIZE    ; reply-port
  2506. PrtIO        rs.b    64    ; IO-request-structuur
  2507.  
  2508. datasize    rs.b    0
  2509.  
  2510.     end
  2511.